{"id":5024,"date":"2022-04-26T16:13:47","date_gmt":"2022-04-26T20:13:47","guid":{"rendered":"https:\/\/www.cloudsurph.com\/?p=5024"},"modified":"2022-06-13T11:15:33","modified_gmt":"2022-06-13T15:15:33","slug":"laravel-how-to-set-up-a-simple-crud","status":"publish","type":"post","link":"https:\/\/www.cloudsurph.com\/laravel-how-to-set-up-a-simple-crud\/","title":{"rendered":"Laravel: How to set up a simple CRUD"},"content":{"rendered":"<h2><strong>Simple Laravel CRUD with Resource Controllers<\/strong><\/h2>\n<p>How to set up a simple Laravel CRUD with Resources Controllers? Creating, reading, updating, and deleting resources is used in a lot of every application.<\/p>\n<h3>How to setup a simple CRUD<\/h3>\n<p>Laravel helps to do the process easily using resource controllers.<\/p>\n<p>Resource Controllers can make life easier and takes advantage of some cool Laravel routing techniques.<\/p>\n<p>Today, we\u2019ll go by the steps essential to get a fully functioning CRUD application using Laravel resource controllers.<\/p>\n<p>For this article, we will go by the steps of having an admin panel to create, read, update, and delete (CRUD) a resource.<\/p>\n<p>Let\u2019s we can use\u00a0csworks\u00a0as our example. Also, we will use\u00a0<a href=\"http:\/\/laravel.com\/docs\/eloquent\">Eloquent ORM<\/a>.<\/p>\n<p><em><strong>IF you want then buy a good, reliable, secure\u00a0WordPress web\u00a0<a href=\"https:\/\/www.cloudsurph.com\/windows-vps-hosting\/\">hosting<\/a>\u00a0service \u00a0from here:\u00a0<a href=\"https:\/\/hosting.cloudsurph.com\/\">click here<\/a><\/strong><\/em><\/p>\n<h3>How to setup a simple CRUD<\/h3>\n<h6>In this article we will show some steps:<\/h6>\n<ul>\n<li>First, Setting up the database and models<\/li>\n<li>Secondly, Creating the resource controller and its routes<\/li>\n<li>Thirdly, Creating the necessary views<\/li>\n<li>Fourthly Explain each method in a resource controller<\/li>\n<\/ul>\n<p>So get started, we will need the\u00a0<strong>routes<\/strong>, the\u00a0<strong>controller<\/strong>, and the\u00a0<strong>view<\/strong>\u00a0files.<\/p>\n<p>Preparing our Database Ready<\/p>\n<h3><em><strong>How to set up a simple Laravel CRUD with Resources Controllers?<\/strong><\/em><\/h3>\n<h4>Cswork Migration<\/h4>\n<p>At first, we need to set up a quick database so we can do all of our CRUD functionality.<\/p>\n<p>So now, In the command line in the root directory of our Laravel application, let\u2019s create a migration.<\/p>\n<div class='et-box et-shadow'>\n\t\t\t\t\t<div class='et-box-content'>php artisan make:migration create_csworkss_table &#8211;table=csworks &#8211;create<\/div><\/div>\n<p>This will create our cswork migration into\u00a0app\/database\/migrations.<\/p>\n<p>Now, open up that file, and let\u2019s add a name, email, and cswork_level fields.<\/p>\n<div class='et-box et-shadow'>\n\t\t\t\t\t<div class='et-box-content'><p>&lt;?php<\/p>\n<p>use IlluminateDatabaseSchemaBlueprint;<\/p>\n<p>use IlluminateDatabaseMigrationsMigration;<\/p>\n<p>class CreatecsworksTable extends Migration {<\/p>\n<p>\/**<\/p>\n<p>* Run the migrations.<\/p>\n<p>*<\/p>\n<p>* @return void<\/p>\n<p>*\/<\/p>\n<p>public function up()<\/p>\n<p>{<\/p>\n<p>Schema::create(&#8216;csworks&#8217;, function(Blueprint $table)<\/p>\n<p>{<\/p>\n<p>$table-&gt;increments(&#8216;id&#8217;);<\/p>\n<p>$table-&gt;string(&#8216;name&#8217;, 255);<\/p>\n<p>$table-&gt;string(&#8217;email&#8217;, 255);<\/p>\n<p>$table-&gt;integer(&#8216;cswork_level&#8217;);<\/p>\n<p>$table-&gt;timestamps();<\/p>\n<p>});<\/p>\n<p>}<\/p>\n<p>\/**<\/p>\n<p>* Reverse the migrations.<\/p>\n<p>*<\/p>\n<p>* @return void<\/p>\n<p>*\/<\/p>\n<p>public function down()<\/p>\n<p>{<\/p>\n<p>Schema::drop(&#8216;csworks&#8217;);<\/p>\n<p>}<\/p>\n<p>}<\/p><\/div><\/div>\n<p>And now from the command line again, we need let\u2019s run this migration.<\/p>\n<p>Make sure our\u00a0<strong>database settings<\/strong>\u00a0are good in\u00a0app\/config\/database.php<\/p>\n<p>And then run: php artisan migrate<\/p>\n<p>Now our database has a csworks table to house all of the csworks we CRUD which means create, read, update, and delete.<\/p>\n<p>If you can read more about migrations then you can check these links\u00a0<a href=\"http:\/\/laravel.com\/docs\/migrations#creating-migrations\">Laravel docs<\/a>.<\/p>\n<h2><em><strong>How to set up a simple Laravel CRUD with Resources Controllers?<\/strong><\/em><\/h2>\n<p><em><strong>You can purchase your\u00a0<a href=\"https:\/\/hosting.cloudsurph.com\/\">hosting from Cloudsurph.com<\/a>,\u00a0<a href=\"https:\/\/hosting.cloudsurph.com\/\">Cloudsurph hosting<\/a>\u00a0is more reliable and comfortable for your business website and it is most secure.<\/strong><\/em><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5026\" src=\"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2022\/04\/Simple-Laravel-CRUD-with-Resource-Controllers.jpg\" alt=\"Simple-Laravel-CRUD-with-Resource-Controllers\" width=\"1280\" height=\"720\" srcset=\"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2022\/04\/Simple-Laravel-CRUD-with-Resource-Controllers.jpg 1280w, https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2022\/04\/Simple-Laravel-CRUD-with-Resource-Controllers-980x551.jpg 980w, https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2022\/04\/Simple-Laravel-CRUD-with-Resource-Controllers-480x270.jpg 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1280px, 100vw\" \/><\/p>\n<h2>Eloquent Model for the csworks<\/h2>\n<h4>So we have our database, and let\u2019s create a simple Eloquent model.<\/h4>\n<p>So that we can easily access the csworks in our database.<\/p>\n<p>You can read more about\u00a0<a href=\"http:\/\/laravel.com\/docs\/eloquent\">Eloquent ORM<\/a>\u00a0and you can see how you can use it in your self-applications.<\/p>\n<p>Now, In the\u00a0app\/models\u00a0folder, let\u2019s create a cswork.php model.<\/p>\n<div class='et-box et-shadow'>\n\t\t\t\t\t<div class='et-box-content'><p>&lt;?php<\/p>\n<p>class cswork extends Eloquent<\/p>\n<p>{<\/p>\n<p>}<\/p><\/div><\/div>\n<p>That\u2019s it for now!<\/p>\n<p>Now, Eloquent can handle the rest.<\/p>\n<p>So, by default, this model will link to our\u00a0csworks\u00a0table and we can access it later for our controllers.<\/p>\n<h2>Creating the Controller<\/h2>\n<p>Check the official Laravel docs, on\u00a0<a href=\"http:\/\/laravel.com\/docs\/controllers#resource-controllers\">resource controllers<\/a>, you can create or generate a resource controller using the artisan tool.<\/p>\n<p>And, let\u2019s go ahead and do that. This is the easy part from the command line in the root directory of your self Laravel project, type: php artisan make:controller csworkController &#8211;resource<\/p>\n<p>It will create our resource controller with all the methods that we need.<\/p>\n<div class='et-box et-shadow'>\n\t\t\t\t\t<div class='et-box-content'><p>&lt;?php<\/p>\n<p>class csworkController extends BaseController {<\/p>\n<p>\/**<\/p>\n<p>* Display a listing of the resource.<\/p>\n<p>*<\/p>\n<p>* @return Response<\/p>\n<p>*\/<\/p>\n<p>public function index()<\/p>\n<p>{<\/p>\n<p>\/\/<\/p>\n<p>}<\/p>\n<p>\/**<\/p>\n<p>* Show the form for creating a new resource.<\/p>\n<p>*<\/p>\n<p>* @return Response<\/p>\n<p>*\/<\/p>\n<p>public function create()<\/p>\n<p>{<\/p>\n<p>\/\/<\/p>\n<p>}<\/p>\n<p>\/**<\/p>\n<p>* Store a newly created resource in storage.<\/p>\n<p>*<\/p>\n<p>* @return Response<\/p>\n<p>*\/<\/p>\n<p>public function store()<\/p>\n<p>{<\/p>\n<p>\/\/<\/p>\n<p>}<\/p>\n<p>\/**<\/p>\n<p>* Display the specified resource.<\/p>\n<p>*<\/p>\n<p>* @param int $id<\/p>\n<p>* @return Response<\/p>\n<p>*\/<\/p>\n<p>public function show($id)<\/p>\n<p>{<\/p>\n<p>\/\/<\/p>\n<p>}<\/p>\n<p>\/**<\/p>\n<p>* Show the form for editing the specified resource.<\/p>\n<p>*<\/p>\n<p>* @param int $id<\/p>\n<p>* @return Response<\/p>\n<p>*\/<\/p>\n<p>public function edit($id)<\/p>\n<p>{<\/p>\n<p>\/\/<\/p>\n<p>}<\/p>\n<p>\/**<\/p>\n<p>* Update the specified resource in storage.<\/p>\n<p>*<\/p>\n<p>* @param int $id<\/p>\n<p>* @return Response<\/p>\n<p>*\/<\/p>\n<p>public function update($id)<\/p>\n<p>{<\/p>\n<p>\/\/<\/p>\n<p>}<\/p>\n<p>\/**<\/p>\n<p>* Remove the specified resource from storage.<\/p>\n<p>*<\/p>\n<p>* @param int $id<\/p>\n<p>* @return Response<\/p>\n<p>*\/<\/p>\n<p>public function destroy($id)<\/p>\n<p>{<\/p>\n<p>\/\/<\/p>\n<p>}<\/p>\n<p>}<\/p><\/div><\/div>\n<h2>Setting Up our Routes<\/h2>\n<p>We have generated our controller, now let\u2019s make sure our application has the routes essential to use it.<\/p>\n<p>So, this is the other easy part for your\u00a0<strong>routes.php<\/strong>\u00a0file, and add this line:<\/p>\n<div class='et-box et-shadow'>\n\t\t\t\t\t<div class='et-box-content'><p>&lt;?php<\/p>\n<p>Route::resource(&#8216;csworks&#8217;, &#8216;csworkController&#8217;);<\/p><\/div><\/div>\n<p>And this will automatically assign more actions to that resource controller.<\/p>\n<p>Now if you need to go to your browser and view your self-application at\u00a0example.com\/csworks, it will correspond to the proper method in your csworkController.<\/p>\n<h2>The Views<\/h2>\n<p>Since we have only four of our routes GET routes.<\/p>\n<p>And we only need four views, in our\u00a0app\/views\u00a0folder, so let\u2019s make those views now.<\/p>\n<div class='et-box et-shadow'>\n\t\t\t\t\t<div class='et-box-content'><p>app<\/p>\n<p>\u2514\u2500\u2500\u2500views<\/p>\n<p>\u2514\u2500\u2500\u2500csworks<\/p>\n<p>\u2502-index.blade.php<\/p>\n<p>\u2502-create.blade.php<\/p>\n<p>\u2502 -show.blade.php<\/p>\n<p>\u2502 -edit.blade.php<\/div><\/div>\n<h2>Making It for All Work Together<\/h2>\n<p>Now we have our\u00a0<strong>database, migrations, and models<\/strong>.<\/p>\n<p>Our\u00a0<strong>controller and routes<\/strong>, and our\u00a0<strong>views<\/strong>.<\/p>\n<p>So let\u2019s make all these things work together and build our application.<\/p>\n<p>Now, we are going to go through the methods created in the resource controller one by one and make sure it all works.<\/p>\n<h4>Controller Function index()<\/h4>\n<p>Since in this function, we will get all the csworks and pass them to the view.<\/p>\n<div class='et-box et-shadow'>\n\t\t\t\t\t<div class='et-box-content'><p>&lt;?php<\/p>\n<p>&#8230;<\/p>\n<p>\/**<\/p>\n<p>* Display a listing of the resource.<\/p>\n<p>*<\/p>\n<p>* @return Response<\/p>\n<p>*\/<\/p>\n<p>public function index()<\/p>\n<p>{<\/p>\n<p>\/\/ get all the csworks<\/p>\n<p>$csworks = cswork::all();<\/p>\n<p>\/\/ load the view and pass the csworks<\/p>\n<p>return View::make(&#8216;csworks.index&#8217;)<\/p>\n<p>-&gt;with(&#8216;csworks&#8217;, $csworks);<\/p>\n<p>}<\/p>\n<p>&#8230;<\/p><\/div><\/div>\n<h4>The View app\/views\/csworks\/index.blade.php<\/h4>\n<p>Now let\u2019s we create our view to loop for over the csworks and display them into a table.<\/p>\n<h3><em><strong>How to set up a simple Laravel CRUD with Resources Controllers?<\/strong><\/em><\/h3>\n<p>And we like using\u00a0<a href=\"http:\/\/getbootstrap.com\/\">Twitter Bootstrap<\/a>\u00a0for our applications, so that the table will be use those classes.<\/p>\n<div class='et-box et-shadow'>\n\t\t\t\t\t<div class='et-box-content'><p>&lt;!DOCTYPE html&gt;<\/p>\n<p>&lt;html&gt;<\/p>\n<p>&lt;head&gt;<\/p>\n<p>&lt;title&gt;Cswork App&lt;\/title&gt;<\/p>\n<p>&lt;link rel=&#8221;stylesheet&#8221; href=&#8221;\/\/netdna.bootstrapcdn.com\/bootstrap\/3.0.0\/css\/bootstrap.min.css&#8221;&gt;<\/p>\n<p>&lt;\/head&gt;<\/p>\n<p>&lt;body&gt;<\/p>\n<p>&lt;div class=&#8221;container&#8221;&gt;<\/p>\n<p>&lt;nav class=&#8221;navbar navbar-inverse&#8221;&gt;<\/p>\n<p>&lt;div class=&#8221;navbar-header&#8221;&gt;<\/p>\n<p>&lt;a class=&#8221;navbar-brand&#8221; href=&#8221;{{ URL::to(&#8216;csworks&#8217;) }}&#8221;&gt;cswork Alert&lt;\/a&gt;<\/p>\n<p>&lt;\/div&gt;<\/p>\n<p>&lt;ul class=&#8221;nav navbar-nav&#8221;&gt;<\/p>\n<p>&lt;li&gt;&lt;a href=&#8221;{{ URL::to(&#8216;csworks&#8217;) }}&#8221;&gt;View All csworks&lt;\/a&gt;&lt;\/li&gt;<\/p>\n<p>&lt;li&gt;&lt;a href=&#8221;{{ URL::to(&#8216;csworks\/create&#8217;) }}&#8221;&gt;Create a cswork&lt;\/a&gt;<\/p>\n<p>&lt;\/ul&gt;<\/p>\n<p>&lt;\/nav&gt;<\/p>\n<p>&lt;h1&gt;All the csworks&lt;\/h1&gt;<\/p>\n<p>&lt;!&#8211; will be used to show any messages &#8211;&gt;<\/p>\n<p>@if (Session::has(&#8216;message&#8217;))<\/p>\n<p>&lt;div class=&#8221;alert alert-info&#8221;&gt;{{ Session::get(&#8216;message&#8217;) }}&lt;\/div&gt;<\/p>\n<p>@endif<\/p>\n<p>&lt;table class=&#8221;table table-striped table-bordered&#8221;&gt;<\/p>\n<p>&lt;thead&gt;<\/p>\n<p>&lt;tr&gt;<\/p>\n<p>&lt;td&gt;ID&lt;\/td&gt;<\/p>\n<p>&lt;td&gt;Name&lt;\/td&gt;<\/p>\n<p>&lt;td&gt;Email&lt;\/td&gt;<\/p>\n<p>&lt;td&gt;cswork Level&lt;\/td&gt;<\/p>\n<p>&lt;td&gt;Actions&lt;\/td&gt;<\/p>\n<p>&lt;\/tr&gt;<\/p>\n<p>&lt;\/thead&gt;<\/p>\n<p>&lt;tbody&gt;<\/p>\n<p>@foreach($csworks as $key =&gt; $value)<\/p>\n<p>&lt;tr&gt;<\/p>\n<p>&lt;td&gt;{{ $value-&gt;id }}&lt;\/td&gt;<\/p>\n<p>&lt;td&gt;{{ $value-&gt;name }}&lt;\/td&gt;<\/p>\n<p>&lt;td&gt;{{ $value-&gt;email }}&lt;\/td&gt;<\/p>\n<p>&lt;td&gt;{{ $value-&gt;cswork_level }}&lt;\/td&gt;<\/p>\n<p>&lt;!&#8211; we will also add show, edit, and delete buttons &#8211;&gt;<\/p>\n<p>&lt;td&gt;<\/p>\n<p>&lt;!&#8211; delete the cswork (uses the destroy method DESTROY \/csworks\/{id} &#8211;&gt;<\/p>\n<p>&lt;!&#8211; we will add this later since its a little more complicated than the other two buttons &#8211;&gt;<\/p>\n<p>&lt;!&#8211; show the cswork (uses the show method found at GET \/csworks\/{id} &#8211;&gt;<\/p>\n<p>&lt;a class=&#8221;btn btn-small btn-success&#8221; href=&#8221;{{ URL::to(&#8216;csworks\/&#8217; . $value-&gt;id) }}&#8221;&gt;Show this cswork&lt;\/a&gt;<\/p>\n<p>&lt;!&#8211; edit this cswork (uses the edit method found at GET \/csworks\/{id}\/edit &#8211;&gt;<\/p>\n<p>&lt;a class=&#8221;btn btn-small btn-info&#8221; href=&#8221;{{ URL::to(&#8216;csworks\/&#8217; . $value-&gt;id . &#8216;\/edit&#8217;) }}&#8221;&gt;Edit this cswork&lt;\/a&gt;<\/p>\n<p>&lt;\/td&gt;<\/p>\n<p>&lt;\/tr&gt;<\/p>\n<p>@endforeach<\/p>\n<p>&lt;\/tbody&gt;<\/p>\n<p>&lt;\/table&gt;<\/p>\n<p>&lt;\/div&gt;<\/p>\n<p>&lt;\/body&gt;<\/p>\n<p>&lt;\/html&gt;<\/p><\/div><\/div>\n<h2>Now create a New Resource csworks.create<\/h2>\n<h4>Controller Function create()<\/h4>\n<p>So, in this function, we will show how to the form for creating a new cswork.<\/p>\n<p>This form will be to the process by the\u00a0store()\u00a0method.<\/p>\n<div class='et-box et-shadow'>\n\t\t\t\t\t<div class='et-box-content'>&lt;?php<\/p>\n<p>&#8230;<\/p>\n<p>\/**<\/p>\n<p>* Show the form for creating a new resource.<\/p>\n<p>*<\/p>\n<p>* @return Response<\/p>\n<p>*\/<\/p>\n<p>public function create()<\/p>\n<p>{<\/p>\n<p>\/\/ load the create form (app\/views\/csworks\/create.blade.php)<\/p>\n<p>return View::make(&#8216;csworks.create&#8217;);<\/p>\n<p>}<\/p>\n<p>&#8230;<\/div><\/div>\n<h3><em><strong>How to set up a simple Laravel CRUD with Resources Controllers?<\/strong><\/em><\/h3>\n<h3>Now, the View app\/views\/csworks\/create.blade.php<\/h3>\n<div class='et-box et-shadow'>\n\t\t\t\t\t<div class='et-box-content'><p>&lt;!DOCTYPE html&gt;<\/p>\n<p>&lt;html&gt;<\/p>\n<p>&lt;head&gt;<\/p>\n<p>&lt;title&gt;Cswork App&lt;\/title&gt;<\/p>\n<p>&lt;link rel=&#8221;stylesheet&#8221; href=&#8221;\/\/netdna.bootstrapcdn.com\/bootstrap\/3.0.0\/css\/bootstrap.min.css&#8221;&gt;<\/p>\n<p>&lt;\/head&gt;<\/p>\n<p>&lt;body&gt;<\/p>\n<p>&lt;div class=&#8221;container&#8221;&gt;<\/p>\n<p>&lt;nav class=&#8221;navbar navbar-inverse&#8221;&gt;<\/p>\n<p>&lt;div class=&#8221;navbar-header&#8221;&gt;<\/p>\n<p>&lt;a class=&#8221;navbar-brand&#8221; href=&#8221;{{ URL::to(&#8216;csworks&#8217;) }}&#8221;&gt;cswork Alert&lt;\/a&gt;<\/p>\n<p>&lt;\/div&gt;<\/p>\n<p>&lt;ul class=&#8221;nav navbar-nav&#8221;&gt;<\/p>\n<p>&lt;li&gt;&lt;a href=&#8221;{{ URL::to(&#8216;csworks&#8217;) }}&#8221;&gt;View All csworks&lt;\/a&gt;&lt;\/li&gt;<\/p>\n<p>&lt;li&gt;&lt;a href=&#8221;{{ URL::to(&#8216;csworks\/create&#8217;) }}&#8221;&gt;Create a cswork&lt;\/a&gt;<\/p>\n<p>&lt;\/ul&gt;<\/p>\n<p>&lt;\/nav&gt;<\/p>\n<p>&lt;h1&gt;Create a cswork&lt;\/h1&gt;<\/p>\n<p>&lt;!&#8211; if there are creation errors, they will show here &#8211;&gt;<\/p>\n<p>{{ HTML::ul($errors-&gt;all()) }}<\/p>\n<p>{{ Form::open(array(&#8216;url&#8217; =&gt; &#8216;csworks&#8217;)) }}<\/p>\n<p>&lt;div class=&#8221;form-group&#8221;&gt;<\/p>\n<p>{{ Form::label(&#8216;name&#8217;, &#8216;Name&#8217;) }}<\/p>\n<p>{{ Form::text(&#8216;name&#8217;, Input::old(&#8216;name&#8217;), array(&#8216;class&#8217; =&gt; &#8216;form-control&#8217;)) }}<\/p>\n<p>&lt;\/div&gt;<\/p>\n<p>&lt;div class=&#8221;form-group&#8221;&gt;<\/p>\n<p>{{ Form::label(&#8217;email&#8217;, &#8216;Email&#8217;) }}<\/p>\n<p>{{ Form::email(&#8217;email&#8217;, Input::old(&#8217;email&#8217;), array(&#8216;class&#8217; =&gt; &#8216;form-control&#8217;)) }}<\/p>\n<p>&lt;\/div&gt;<\/p>\n<p>&lt;div class=&#8221;form-group&#8221;&gt;<\/p>\n<p>{{ Form::label(&#8216;cswork_level&#8217;, &#8216;cswork Level&#8217;) }}<\/p>\n<p>{{ Form::select(&#8216;cswork_level&#8217;, array(&#8216;0&#8217; =&gt; &#8216;Select a Level&#8217;, &#8216;1&#8217; =&gt; &#8216;Sees Sunlight&#8217;, &#8216;2&#8217; =&gt; &#8216;Foosball Fanatic&#8217;, &#8216;3&#8217; =&gt; &#8216;Basement Dweller&#8217;), Input::old(&#8216;cswork_level&#8217;), array(&#8216;class&#8217; =&gt; &#8216;form-control&#8217;)) }}<\/p>\n<p>&lt;\/div&gt;<\/p>\n<p>{{ Form::submit(&#8216;Create the cswork!&#8217;, array(&#8216;class&#8217; =&gt; &#8216;btn btn-primary&#8217;)) }}<\/p>\n<p>{{ Form::close() }}<\/p>\n<p>&lt;\/div&gt;<\/p>\n<p>&lt;\/body&gt;<\/p>\n<p>&lt;\/html&gt;<\/p><\/div><\/div>\n<h2><em><strong>How to set up a simple Laravel CRUD with Resources Controllers?<\/strong><\/em><\/h2>\n<p>To step the form, we will want to\u00a0<strong>validate the inputs<\/strong>\u00a0and <strong>send back error messages if they exist<\/strong> and <strong>authenticate against the database<\/strong>, and\u00a0<strong>store the resource if all is good<\/strong>.<\/p>\n<h2>Controller Function store()<\/h2>\n<div class='et-box et-shadow'>\n\t\t\t\t\t<div class='et-box-content'><p>&lt;?php<\/p>\n<p>&#8230;<\/p>\n<p>\/**<\/p>\n<p>* Store a newly created resource in storage.<\/p>\n<p>*<\/p>\n<p>* @return Response<\/p>\n<p>*\/<\/p>\n<p>public function store()<\/p>\n<p>{<\/p>\n<p>\/\/ validate<\/p>\n<p>\/\/ read more on validation at http:\/\/laravel.com\/docs\/validation<\/p>\n<p>$rules = array(<\/p>\n<p>&#8216;name&#8217; =&gt; &#8216;required&#8217;,<\/p>\n<p>&#8217;email&#8217; =&gt; &#8216;required|email&#8217;,<\/p>\n<p>&#8216;cswork_level&#8217; =&gt; &#8216;required|numeric&#8217;<\/p>\n<p>);<\/p>\n<p>$validator = Validator::make(Input::all(), $rules);<\/p>\n<p>\/\/ process the login<\/p>\n<p>if ($validator-&gt;fails()) {<\/p>\n<p>return Redirect::to(&#8216;csworks\/create&#8217;)<\/p>\n<p>-&gt;withErrors($validator)<\/p>\n<p>-&gt;withInput(Input::except(&#8216;password&#8217;));<\/p>\n<p>} else {<\/p>\n<p>\/\/ store<\/p>\n<p>$cswork = new cswork;<\/p>\n<p>$cswork-&gt;name = Input::get(&#8216;name&#8217;);<\/p>\n<p>$cswork-&gt;email = Input::get(&#8217;email&#8217;);<\/p>\n<p>$cswork-&gt;cswork_level = Input::get(&#8216;cswork_level&#8217;);<\/p>\n<p>$cswork-&gt;save();<\/p>\n<p>\/\/ redirect<\/p>\n<p>Session::flash(&#8216;message&#8217;, &#8216;Successfully created cswork!&#8217;);<\/p>\n<p>return Redirect::to(&#8216;csworks&#8217;);<\/p>\n<p>}<\/p>\n<p>}<\/p><\/div><\/div>\n<p>Here now you should be able to create a cswork and have them show up on the main landing page!<\/p>\n<p>And navigate to\u00a0example.com\/csworks\u00a0and there they are.<\/p>\n<p>All that\u2019s left is\u00a0<strong>showing a single cswork<\/strong>,\u00a0<strong>updating<\/strong>, and\u00a0<strong>deleting<\/strong>.<\/p>\n<h4>Controller Function show()<\/h4>\n<div class='et-box et-shadow'>\n\t\t\t\t\t<div class='et-box-content'><p>&lt;?php<\/p>\n<p>&#8230;<\/p>\n<p>\/**<\/p>\n<p>* Display the specified resource.<\/p>\n<p>*<\/p>\n<p>* @param int $id<\/p>\n<p>* @return Response<\/p>\n<p>*\/<\/p>\n<p>public function show($id)<\/p>\n<p>{<\/p>\n<p>\/\/ get the cswork<\/p>\n<p>$cswork = cswork::find($id);<\/p>\n<p>\/\/ show the view and pass the cswork to it<\/p>\n<p>return View::make(&#8216;csworks.show&#8217;)<\/p>\n<p>-&gt;with(&#8216;cswork&#8217;, $cswork);<\/p>\n<p>}<\/p>\n<p>&#8230;<\/p><\/div><\/div>\n<h4>The View app\/views\/csworks\/show.blade.php<\/h4>\n<div class='et-box et-shadow'>\n\t\t\t\t\t<div class='et-box-content'><p>&lt;!DOCTYPE html&gt;<\/p>\n<p>&lt;html&gt;<\/p>\n<p>&lt;head&gt;<\/p>\n<p>&lt;title&gt;Cswork App&lt;\/title&gt;<\/p>\n<p>&lt;link rel=&#8221;stylesheet&#8221; href=&#8221;\/\/netdna.bootstrapcdn.com\/bootstrap\/3.0.0\/css\/bootstrap.min.css&#8221;&gt;<\/p>\n<p>&lt;\/head&gt;<\/p>\n<p>&lt;body&gt;<\/p>\n<p>&lt;div class=&#8221;container&#8221;&gt;<\/p>\n<p>&lt;nav class=&#8221;navbar navbar-inverse&#8221;&gt;<\/p>\n<p>&lt;div class=&#8221;navbar-header&#8221;&gt;<\/p>\n<p>&lt;a class=&#8221;navbar-brand&#8221; href=&#8221;{{ URL::to(&#8216;csworks&#8217;) }}&#8221;&gt;cswork Alert&lt;\/a&gt;<\/p>\n<p>&lt;\/div&gt;<\/p>\n<p>&lt;ul class=&#8221;nav navbar-nav&#8221;&gt;<\/p>\n<p>&lt;li&gt;&lt;a href=&#8221;{{ URL::to(&#8216;csworks&#8217;) }}&#8221;&gt;View All csworks&lt;\/a&gt;&lt;\/li&gt;<\/p>\n<p>&lt;li&gt;&lt;a href=&#8221;{{ URL::to(&#8216;csworks\/create&#8217;) }}&#8221;&gt;Create a cswork&lt;\/a&gt;&lt;\/li&gt;<\/p>\n<p>&lt;\/ul&gt;<\/p>\n<p>&lt;\/nav&gt;<\/p>\n<p>&lt;h1&gt;Showing {{ $cswork-&gt;name }}&lt;\/h1&gt;<\/p>\n<p>&lt;div class=&#8221;jumbotron text-center&#8221;&gt;<\/p>\n<p>&lt;h2&gt;{{ $cswork-&gt;name }}&lt;\/h2&gt;<\/p>\n<p>&lt;p&gt;<\/p>\n<p>&lt;strong&gt;Email:&lt;\/strong&gt; {{ $cswork-&gt;email }}&lt;br&gt;<\/p>\n<p>&lt;strong&gt;Level:&lt;\/strong&gt; {{ $cswork-&gt;cswork_level }}<\/p>\n<p>&lt;\/p&gt;<\/p>\n<p>&lt;\/div&gt;<\/p>\n<p>&lt;\/div&gt;<\/p>\n<p>&lt;\/body&gt;<\/p>\n<p>&lt;\/html&gt;<\/p><\/div><\/div>\n<h2><em><strong>How to set up a simple Laravel CRUD with Resources Controllers?<\/strong><\/em><\/h2>\n<h3>Editing a Resource edit()<\/h3>\n<p>We, just makes it easier to populate our edit form and you can imagine that when these forms start getting rather bigger this will make life easier.<\/p>\n<h2>Controller Function edit()<\/h2>\n<div class='et-box et-shadow'>\n\t\t\t\t\t<div class='et-box-content'><p>&lt;?php<\/p>\n<p>&#8230;<\/p>\n<p>\/**<\/p>\n<p>* Show the form for editing the specified resource.<\/p>\n<p>*<\/p>\n<p>* @param int $id<\/p>\n<p>* @return Response<\/p>\n<p>*\/<\/p>\n<p>public function edit($id)<\/p>\n<p>{<\/p>\n<p>\/\/ get the cswork<\/p>\n<p>$cswork = cswork::find($id);<\/p>\n<p>\/\/ show the edit form and pass the cswork<\/p>\n<p>return View::make(&#8216;csworks.edit&#8217;)<\/p>\n<p>-&gt;with(&#8216;cswork&#8217;, $cswork);<\/p>\n<p>}<\/p>\n<p>&#8230;<\/p><\/div><\/div>\n<h2><strong>How to set up a simple Laravel CRUD with Resources Controllers?<\/strong><\/h2>\n<h4>The View app\/views\/csworks\/edit.blade.php<\/h4>\n<div class='et-box et-shadow'>\n\t\t\t\t\t<div class='et-box-content'><p>&lt;!DOCTYPE html&gt;<\/p>\n<p>&lt;html&gt;<\/p>\n<p>&lt;head&gt;<\/p>\n<p>&lt;title&gt;Cswork App&lt;\/title&gt;<\/p>\n<p>&lt;link rel=&#8221;stylesheet&#8221; href=&#8221;\/\/netdna.bootstrapcdn.com\/bootstrap\/3.0.0\/css\/bootstrap.min.css&#8221;&gt;<\/p>\n<p>&lt;\/head&gt;<\/p>\n<p>&lt;body&gt;<\/p>\n<p>&lt;div class=&#8221;container&#8221;&gt;<\/p>\n<p>&lt;nav class=&#8221;navbar navbar-inverse&#8221;&gt;<\/p>\n<p>&lt;div class=&#8221;navbar-header&#8221;&gt;<\/p>\n<p>&lt;a class=&#8221;navbar-brand&#8221; href=&#8221;{{ URL::to(&#8216;csworks&#8217;) }}&#8221;&gt;cswork Alert&lt;\/a&gt;<\/p>\n<p>&lt;\/div&gt;<\/p>\n<p>&lt;ul class=&#8221;nav navbar-nav&#8221;&gt;<\/p>\n<p>&lt;li&gt;&lt;a href=&#8221;{{ URL::to(&#8216;csworks&#8217;) }}&#8221;&gt;View All csworks&lt;\/a&gt;&lt;\/li&gt;<\/p>\n<p>&lt;li&gt;&lt;a href=&#8221;{{ URL::to(&#8216;csworks\/create&#8217;) }}&#8221;&gt;Create a cswork&lt;\/a&gt;&lt;\/lI&gt;<\/p>\n<p>&lt;\/ul&gt;<\/p>\n<p>&lt;\/nav&gt;<\/p>\n<p>&lt;h1&gt;Edit {{ $cswork-&gt;name }}&lt;\/h1&gt;<\/p>\n<p>&lt;!&#8211; if there are creation errors, they will show here &#8211;&gt;<\/p>\n<p>{{ HTML::ul($errors-&gt;all()) }}<\/p>\n<p>{{ Form::model($cswork, array(&#8216;route&#8217; =&gt; array(&#8216;csworks.update&#8217;, $cswork-&gt;id), &#8216;method&#8217; =&gt; &#8216;PUT&#8217;)) }}<\/p>\n<p>&lt;div class=&#8221;form-group&#8221;&gt;<\/p>\n<p>{{ Form::label(&#8216;name&#8217;, &#8216;Name&#8217;) }}<\/p>\n<p>{{ Form::text(&#8216;name&#8217;, null, array(&#8216;class&#8217; =&gt; &#8216;form-control&#8217;)) }}<\/p>\n<p>&lt;\/div&gt;<\/p>\n<p>&lt;div class=&#8221;form-group&#8221;&gt;<\/p>\n<p>{{ Form::label(&#8217;email&#8217;, &#8216;Email&#8217;) }}<\/p>\n<p>{{ Form::email(&#8217;email&#8217;, null, array(&#8216;class&#8217; =&gt; &#8216;form-control&#8217;)) }}<\/p>\n<p>&lt;\/div&gt;<\/p>\n<p>&lt;div class=&#8221;form-group&#8221;&gt;<\/p>\n<p>{{ Form::label(&#8216;cswork_level&#8217;, &#8216;cswork Level&#8217;) }}<\/p>\n<p>{{ Form::select(&#8216;cswork_level&#8217;, array(&#8216;0&#8217; =&gt; &#8216;Select a Level&#8217;, &#8216;1&#8217; =&gt; &#8216;Sees Sunlight&#8217;, &#8216;2&#8217; =&gt; &#8216;Foosball Fanatic&#8217;, &#8216;3&#8217; =&gt; &#8216;Basement Dweller&#8217;), null, array(&#8216;class&#8217; =&gt; &#8216;form-control&#8217;)) }}<\/p>\n<p>&lt;\/div&gt;<\/p>\n<p>{{ Form::submit(&#8216;Edit cswork!&#8217;, array(&#8216;class&#8217; =&gt; &#8216;btn btn-primary&#8217;)) }}<\/p>\n<p>{{ Form::close() }}<\/p>\n<p>&lt;\/div&gt;<\/p>\n<p>&lt;\/body&gt;<\/p>\n<p>&lt;\/html&gt;<\/p><\/div><\/div>\n<h3>Updating a Resource update()<\/h3>\n<p>Now, this controller method will process the edit form. It is very easy to\u00a0store(). And we will\u00a0<strong>validate<\/strong>,\u00a0<strong>update<\/strong>, and\u00a0<strong>redirect<\/strong>.<\/p>\n<h4>Controller Function update()<\/h4>\n<div class='et-box et-shadow'>\n\t\t\t\t\t<div class='et-box-content'><p>&lt;?php<\/p>\n<p>&#8230;<\/p>\n<p>\/**<\/p>\n<p>* Update the specified resource in storage.<\/p>\n<p>*<\/p>\n<p>* @param int $id<\/p>\n<p>* @return Response<\/p>\n<p>*\/<\/p>\n<p>public function update($id)<\/p>\n<p>{<\/p>\n<p>\/\/ validate<\/p>\n<p>\/\/ read more on validation at http:\/\/laravel.com\/docs\/validation<\/p>\n<p>$rules = array(<\/p>\n<p>&#8216;name&#8217; =&gt; &#8216;required&#8217;,<\/p>\n<p>&#8217;email&#8217; =&gt; &#8216;required|email&#8217;,<\/p>\n<p>&#8216;cswork_level&#8217; =&gt; &#8216;required|numeric&#8217;<\/p>\n<p>);<\/p>\n<p>$validator = Validator::make(Input::all(), $rules);<\/p>\n<p>\/\/ process the login<\/p>\n<p>if ($validator-&gt;fails()) {<\/p>\n<p>return Redirect::to(&#8216;csworks\/&#8217; . $id . &#8216;\/edit&#8217;)<\/p>\n<p>-&gt;withErrors($validator)<\/p>\n<p>-&gt;withInput(Input::except(&#8216;password&#8217;));<\/p>\n<p>} else {<\/p>\n<p>\/\/ store<\/p>\n<p>$cswork = cswork::find($id);<\/p>\n<p>$cswork-&gt;name = Input::get(&#8216;name&#8217;);<\/p>\n<p>$cswork-&gt;email = Input::get(&#8217;email&#8217;);<\/p>\n<p>$cswork-&gt;cswork_level = Input::get(&#8216;cswork_level&#8217;);<\/p>\n<p>$cswork-&gt;save();<\/p>\n<p>\/\/ redirect<\/p>\n<p>Session::flash(&#8216;message&#8217;, &#8216;Successfully updated cswork!&#8217;);<\/p>\n<p>return Redirect::to(&#8216;csworks&#8217;);<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>&#8230;<\/p><\/div><\/div>\n<h3>Deleting a Resource destroy()<\/h3>\n<p>In this workflow, you can see a delete button, and click it to delete.<\/p>\n<p>Since we never created a delete button in our\u00a0app\/views\/csworks\/index.blade.php,<\/p>\n<p>Now, we will create that and we will also add a notification section to show a success message.<\/p>\n<h4>The View app\/views\/csworks\/index.blade.php<\/h4>\n<div class='et-box et-shadow'>\n\t\t\t\t\t<div class='et-box-content'><p>&#8230;<\/p>\n<p>@foreach($csworks as $key =&gt; $value)<\/p>\n<p>&lt;tr&gt;<\/p>\n<p>&lt;td&gt;{{ $value-&gt;id }}&lt;\/td&gt;<\/p>\n<p>&lt;td&gt;{{ $value-&gt;name }}&lt;\/td&gt;<\/p>\n<p>&lt;td&gt;{{ $value-&gt;email }}&lt;\/td&gt;<\/p>\n<p>&lt;td&gt;{{ $value-&gt;cswork_level }}&lt;\/td&gt;<\/p>\n<p>&lt;!&#8211; we will also add show, edit, and delete buttons &#8211;&gt;<\/p>\n<p>&lt;td&gt;<\/p>\n<p>&lt;!&#8211; delete the cswork (uses the destroy method DESTROY \/csworks\/{id} &#8211;&gt;<\/p>\n<p>&lt;!&#8211; we will add this later since its a little more complicated than the other two buttons &#8211;&gt;<\/p>\n<p>{{ Form::open(array(&#8216;url&#8217; =&gt; &#8216;csworks\/&#8217; . $value-&gt;id, &#8216;class&#8217; =&gt; &#8216;pull-right&#8217;)) }}<\/p>\n<p>{{ Form::hidden(&#8216;_method&#8217;, &#8216;DELETE&#8217;) }}<\/p>\n<p>{{ Form::submit(&#8216;Delete this cswork&#8217;, array(&#8216;class&#8217; =&gt; &#8216;btn btn-warning&#8217;)) }}<\/p>\n<p>{{ Form::close() }}<\/p>\n<p>&lt;!&#8211; show the cswork (uses the show method found at GET \/csworks\/{id} &#8211;&gt;<\/p>\n<p>&lt;a class=&#8221;btn btn-small btn-success&#8221; href=&#8221;{{ URL::to(&#8216;csworks\/&#8217; . $value-&gt;id) }}&#8221;&gt;Show this cswork&lt;\/a&gt;<\/p>\n<p>&lt;!&#8211; edit this cswork (uses the edit method found at GET \/csworks\/{id}\/edit &#8211;&gt;<\/p>\n<p>&lt;a class=&#8221;btn btn-small btn-info&#8221; href=&#8221;{{ URL::to(&#8216;csworks\/&#8217; . $value-&gt;id . &#8216;\/edit&#8217;) }}&#8221;&gt;Edit this cswork&lt;\/a&gt;<\/p>\n<p>&lt;\/td&gt;<\/p>\n<p>&lt;\/tr&gt;<\/p>\n<p>@endforeach<\/p>\n<p>&#8230;<\/p><\/div><\/div>\n<p>Now if we click that form submit button, Laravel will use the csworks.destroy route and we can process that in our controller.<\/p>\n<h4>Controller Function destroy()<\/h4>\n<div class='et-box et-shadow'>\n\t\t\t\t\t<div class='et-box-content'><p>&lt;?php<\/p>\n<p>&#8230;<\/p>\n<p>\/**<\/p>\n<p>* Remove the specified resource from storage.<\/p>\n<p>*<\/p>\n<p>* @param int $id<\/p>\n<p>* @return Response<\/p>\n<p>*\/<\/p>\n<p>public function destroy($id)<\/p>\n<p>{<\/p>\n<p>\/\/ delete<\/p>\n<p>$cswork = cswork::find($id);<\/p>\n<p>$cswork-&gt;delete();<\/p>\n<p>\/\/ redirect<\/p>\n<p>Session::flash(&#8216;message&#8217;, &#8216;Successfully deleted the cswork!&#8217;);<\/p>\n<p>return Redirect::to(&#8216;csworks&#8217;);<\/p>\n<p>}<\/p>\n<p>&#8230;<\/p><\/div><\/div>\n<h2>Conclusion<\/h2>\n<p>So, we get to know enough so that we can understand and how to resource controllers can be used in all. And just create the single line in the routes file, create the controller, and you have the foundation for doing CRUD.<\/p>\n<p>If you enjoyed reading this article and have more questions please reach out to our <a href=\"https:\/\/hosting.cloudsurph.com\/submitticket.php?step=2&amp;deptid=1\">support team<\/a>\u00a0via live chat or\u00a0<a href=\"mailto:support@cloudsurph.com\">email<\/a>\u00a0and we would be glad to help you. we provide server\u00a0<a href=\"https:\/\/hosting.cloudsurph.com\/\">hosting<\/a>\u00a0for all types of need and we can even get your\u00a0<a href=\"https:\/\/hosting.cloudsurph.com\/\">server<\/a>\u00a0up and running with the service of your choice.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Simple Laravel CRUD with Resource Controllers How to set up a simple Laravel CRUD with Resources Controllers? Creating, reading, updating, and deleting resources is used in a lot of every application. How to setup a simple CRUD Laravel helps to do the process easily using resource controllers. Resource Controllers can make life easier and takes [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":5025,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[25,150,44,1,31],"tags":[54,47,105,103,48,113],"class_list":["post-5024","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web-hosting-virtualization","category-laravel","category-kvm-xen","category-virtual-private-servers","category-web-hosting","tag-best-vps-hosting-server-maryland","tag-cheap-cloud-servers","tag-cheap-storage-server-hosting","tag-cheapest-vps","tag-dedicated-server-hosting-in-washington-d-c","tag-speed-test-vps"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to set up a simple Laravel CRUD with Resources Controllers?<\/title>\n<meta name=\"description\" content=\"How to set up a simple Laravel CRUD with Resources Controllers, Creating, reading, updating, and deleting resources.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.cloudsurph.com\/laravel-how-to-set-up-a-simple-crud\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to set up a simple Laravel CRUD with Resources Controllers?\" \/>\n<meta property=\"og:description\" content=\"How to set up a simple Laravel CRUD with Resources Controllers, Creating, reading, updating, and deleting resources.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.cloudsurph.com\/laravel-how-to-set-up-a-simple-crud\/\" \/>\n<meta property=\"og:site_name\" content=\"Cloudsurph Web Hosting Washington D.C.\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/CloudSurph\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-04-26T20:13:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-06-13T15:15:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2022\/04\/Laravel-how-to-setup-a-simple-CRUD.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Rony\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@cloudsurph\" \/>\n<meta name=\"twitter:site\" content=\"@Cloud_Surph\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rony\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/laravel-how-to-set-up-a-simple-crud\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/laravel-how-to-set-up-a-simple-crud\\\/\"},\"author\":{\"name\":\"Rony\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#\\\/schema\\\/person\\\/ac9b4dd136d96e50d5f29c560191e7ed\"},\"headline\":\"Laravel: How to set up a simple CRUD\",\"datePublished\":\"2022-04-26T20:13:47+00:00\",\"dateModified\":\"2022-06-13T15:15:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/laravel-how-to-set-up-a-simple-crud\\\/\"},\"wordCount\":3208,\"publisher\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/laravel-how-to-set-up-a-simple-crud\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.cloudsurph.com\\\/wp-content\\\/uploads\\\/2022\\\/04\\\/Laravel-how-to-setup-a-simple-CRUD.jpg\",\"keywords\":[\"Best VPS hosting server Maryland\",\"Cheap Cloud Servers\",\"Cheap Storage Server Hosting\",\"Cheapest VPS\",\"Dedicated Server Hosting in Washington D.C\",\"Speed test VPS\"],\"articleSection\":[\"Cloud Hosting\",\"Laravel\",\"Virtualization\",\"VPS Servers\",\"Web Hosting\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/laravel-how-to-set-up-a-simple-crud\\\/\",\"url\":\"https:\\\/\\\/www.cloudsurph.com\\\/laravel-how-to-set-up-a-simple-crud\\\/\",\"name\":\"How to set up a simple Laravel CRUD with Resources Controllers?\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/laravel-how-to-set-up-a-simple-crud\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/laravel-how-to-set-up-a-simple-crud\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.cloudsurph.com\\\/wp-content\\\/uploads\\\/2022\\\/04\\\/Laravel-how-to-setup-a-simple-CRUD.jpg\",\"datePublished\":\"2022-04-26T20:13:47+00:00\",\"dateModified\":\"2022-06-13T15:15:33+00:00\",\"description\":\"How to set up a simple Laravel CRUD with Resources Controllers, Creating, reading, updating, and deleting resources.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/laravel-how-to-set-up-a-simple-crud\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.cloudsurph.com\\\/laravel-how-to-set-up-a-simple-crud\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/laravel-how-to-set-up-a-simple-crud\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.cloudsurph.com\\\/wp-content\\\/uploads\\\/2022\\\/04\\\/Laravel-how-to-setup-a-simple-CRUD.jpg\",\"contentUrl\":\"https:\\\/\\\/www.cloudsurph.com\\\/wp-content\\\/uploads\\\/2022\\\/04\\\/Laravel-how-to-setup-a-simple-CRUD.jpg\",\"width\":1280,\"height\":720},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/laravel-how-to-set-up-a-simple-crud\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.cloudsurph.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Laravel: How to set up a simple CRUD\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#website\",\"url\":\"https:\\\/\\\/www.cloudsurph.com\\\/\",\"name\":\"Cloudsurph Web Hosting Washington D.C.\",\"description\":\"Dedicated Server Hosting\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.cloudsurph.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#organization\",\"name\":\"CloudSurph Technology Solutions\",\"url\":\"https:\\\/\\\/www.cloudsurph.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.cloudsurph.com\\\/wp-content\\\/uploads\\\/2016\\\/04\\\/cloudsurph-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.cloudsurph.com\\\/wp-content\\\/uploads\\\/2016\\\/04\\\/cloudsurph-logo.png\",\"width\":2348,\"height\":1692,\"caption\":\"CloudSurph Technology Solutions\"},\"image\":{\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/CloudSurph\\\/\",\"https:\\\/\\\/x.com\\\/Cloud_Surph\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.cloudsurph.com\\\/#\\\/schema\\\/person\\\/ac9b4dd136d96e50d5f29c560191e7ed\",\"name\":\"Rony\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/40163fe1eb49d5eddd81954e8ad5122633e141df15b0733d07fbe4a156688ba5?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/40163fe1eb49d5eddd81954e8ad5122633e141df15b0733d07fbe4a156688ba5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/40163fe1eb49d5eddd81954e8ad5122633e141df15b0733d07fbe4a156688ba5?s=96&d=mm&r=g\",\"caption\":\"Rony\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/cloudsurph\"],\"url\":\"https:\\\/\\\/www.cloudsurph.com\\\/author\\\/ron\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to set up a simple Laravel CRUD with Resources Controllers?","description":"How to set up a simple Laravel CRUD with Resources Controllers, Creating, reading, updating, and deleting resources.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.cloudsurph.com\/laravel-how-to-set-up-a-simple-crud\/","og_locale":"en_US","og_type":"article","og_title":"How to set up a simple Laravel CRUD with Resources Controllers?","og_description":"How to set up a simple Laravel CRUD with Resources Controllers, Creating, reading, updating, and deleting resources.","og_url":"https:\/\/www.cloudsurph.com\/laravel-how-to-set-up-a-simple-crud\/","og_site_name":"Cloudsurph Web Hosting Washington D.C.","article_publisher":"https:\/\/www.facebook.com\/CloudSurph\/","article_published_time":"2022-04-26T20:13:47+00:00","article_modified_time":"2022-06-13T15:15:33+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2022\/04\/Laravel-how-to-setup-a-simple-CRUD.jpg","type":"image\/jpeg"}],"author":"Rony","twitter_card":"summary_large_image","twitter_creator":"@cloudsurph","twitter_site":"@Cloud_Surph","twitter_misc":{"Written by":"Rony","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.cloudsurph.com\/laravel-how-to-set-up-a-simple-crud\/#article","isPartOf":{"@id":"https:\/\/www.cloudsurph.com\/laravel-how-to-set-up-a-simple-crud\/"},"author":{"name":"Rony","@id":"https:\/\/www.cloudsurph.com\/#\/schema\/person\/ac9b4dd136d96e50d5f29c560191e7ed"},"headline":"Laravel: How to set up a simple CRUD","datePublished":"2022-04-26T20:13:47+00:00","dateModified":"2022-06-13T15:15:33+00:00","mainEntityOfPage":{"@id":"https:\/\/www.cloudsurph.com\/laravel-how-to-set-up-a-simple-crud\/"},"wordCount":3208,"publisher":{"@id":"https:\/\/www.cloudsurph.com\/#organization"},"image":{"@id":"https:\/\/www.cloudsurph.com\/laravel-how-to-set-up-a-simple-crud\/#primaryimage"},"thumbnailUrl":"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2022\/04\/Laravel-how-to-setup-a-simple-CRUD.jpg","keywords":["Best VPS hosting server Maryland","Cheap Cloud Servers","Cheap Storage Server Hosting","Cheapest VPS","Dedicated Server Hosting in Washington D.C","Speed test VPS"],"articleSection":["Cloud Hosting","Laravel","Virtualization","VPS Servers","Web Hosting"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.cloudsurph.com\/laravel-how-to-set-up-a-simple-crud\/","url":"https:\/\/www.cloudsurph.com\/laravel-how-to-set-up-a-simple-crud\/","name":"How to set up a simple Laravel CRUD with Resources Controllers?","isPartOf":{"@id":"https:\/\/www.cloudsurph.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.cloudsurph.com\/laravel-how-to-set-up-a-simple-crud\/#primaryimage"},"image":{"@id":"https:\/\/www.cloudsurph.com\/laravel-how-to-set-up-a-simple-crud\/#primaryimage"},"thumbnailUrl":"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2022\/04\/Laravel-how-to-setup-a-simple-CRUD.jpg","datePublished":"2022-04-26T20:13:47+00:00","dateModified":"2022-06-13T15:15:33+00:00","description":"How to set up a simple Laravel CRUD with Resources Controllers, Creating, reading, updating, and deleting resources.","breadcrumb":{"@id":"https:\/\/www.cloudsurph.com\/laravel-how-to-set-up-a-simple-crud\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.cloudsurph.com\/laravel-how-to-set-up-a-simple-crud\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.cloudsurph.com\/laravel-how-to-set-up-a-simple-crud\/#primaryimage","url":"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2022\/04\/Laravel-how-to-setup-a-simple-CRUD.jpg","contentUrl":"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2022\/04\/Laravel-how-to-setup-a-simple-CRUD.jpg","width":1280,"height":720},{"@type":"BreadcrumbList","@id":"https:\/\/www.cloudsurph.com\/laravel-how-to-set-up-a-simple-crud\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.cloudsurph.com\/"},{"@type":"ListItem","position":2,"name":"Laravel: How to set up a simple CRUD"}]},{"@type":"WebSite","@id":"https:\/\/www.cloudsurph.com\/#website","url":"https:\/\/www.cloudsurph.com\/","name":"Cloudsurph Web Hosting Washington D.C.","description":"Dedicated Server Hosting","publisher":{"@id":"https:\/\/www.cloudsurph.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.cloudsurph.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.cloudsurph.com\/#organization","name":"CloudSurph Technology Solutions","url":"https:\/\/www.cloudsurph.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.cloudsurph.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2016\/04\/cloudsurph-logo.png","contentUrl":"https:\/\/www.cloudsurph.com\/wp-content\/uploads\/2016\/04\/cloudsurph-logo.png","width":2348,"height":1692,"caption":"CloudSurph Technology Solutions"},"image":{"@id":"https:\/\/www.cloudsurph.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/CloudSurph\/","https:\/\/x.com\/Cloud_Surph"]},{"@type":"Person","@id":"https:\/\/www.cloudsurph.com\/#\/schema\/person\/ac9b4dd136d96e50d5f29c560191e7ed","name":"Rony","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/40163fe1eb49d5eddd81954e8ad5122633e141df15b0733d07fbe4a156688ba5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/40163fe1eb49d5eddd81954e8ad5122633e141df15b0733d07fbe4a156688ba5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/40163fe1eb49d5eddd81954e8ad5122633e141df15b0733d07fbe4a156688ba5?s=96&d=mm&r=g","caption":"Rony"},"sameAs":["https:\/\/x.com\/cloudsurph"],"url":"https:\/\/www.cloudsurph.com\/author\/ron\/"}]}},"_links":{"self":[{"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/posts\/5024","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/comments?post=5024"}],"version-history":[{"count":6,"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/posts\/5024\/revisions"}],"predecessor-version":[{"id":5028,"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/posts\/5024\/revisions\/5028"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/media\/5025"}],"wp:attachment":[{"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/media?parent=5024"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/categories?post=5024"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cloudsurph.com\/wp-json\/wp\/v2\/tags?post=5024"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}