<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>laravel crud operations Archives - scmGalaxy</title>
	<atom:link href="https://www.scmgalaxy.com/tutorials/tag/laravel-crud-operations/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.scmgalaxy.com/tutorials/tag/laravel-crud-operations/</link>
	<description>A Platform for Software Engineers</description>
	<lastBuildDate>Mon, 12 Jul 2021 09:27:44 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1</generator>
	<item>
		<title>CRUD OPERATIONS IN LARAVEL PHP FRAMEWORK</title>
		<link>https://www.scmgalaxy.com/tutorials/crud-operations-in-laravel-php-framework/</link>
					<comments>https://www.scmgalaxy.com/tutorials/crud-operations-in-laravel-php-framework/#respond</comments>
		
		<dc:creator><![CDATA[rishav]]></dc:creator>
		<pubDate>Sat, 20 Mar 2021 12:31:57 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<category><![CDATA[crud operations]]></category>
		<category><![CDATA[laravel]]></category>
		<category><![CDATA[laravel crud operations]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/?p=5686</guid>

					<description><![CDATA[<p>Crud is simply the basis of any web/app development features. All we have to do on any web page is [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/crud-operations-in-laravel-php-framework/">CRUD OPERATIONS IN LARAVEL PHP FRAMEWORK</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="has-black-color has-cyan-bluish-gray-background-color has-text-color has-background has-medium-font-size wp-block-paragraph">Crud is simply the basis of any web/app development features. All we have to do on any web page is Creating, Reading, Deleting, or Updating the content and that is known as the acronym CRUD. In this blog, we learn about how we perform CRUD operation in Laravel 5.8(PHP framework).</p>



<h3 class="wp-block-heading">Step 0: Prerequisite</h3>



<ul class="wp-block-list"><li>Install <strong>xampp </strong>a PHP development environment. (Version 7.4 best suited for 5.8 Laravel)</li><li>Install <strong>composer</strong>(to install libraries of Php for any application).</li><li>Install <strong>VS code</strong>(Code-editor).</li></ul>



<h3 class="has-black-color has-text-color wp-block-heading">Step 1 : Download/install Laravel 5.8</h3>



<p class="wp-block-paragraph">Go to command prompt and then go to the xampp folder in C drive by cmd.<strong> [C:\xampp\htdocs\]</strong></p>



<p class="wp-block-paragraph">In cmd Run : </p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
composer create-project laravel/laravel=5.8 crud --prefer-dist
</pre></div>


<p class="wp-block-paragraph"><em>It will install laravel 5.8 in your xampp/htdocs folder, and the folder name in which the Laravel is installed is &#8220;crud&#8221;(You can change this name of the folder while writing the command in cmd)</em>.</p>



<h3 class="wp-block-heading">Step 2 : Create the Database </h3>



<p class="wp-block-paragraph">For the connection of the database first we have to run <strong><em>&#8220;xampp control pannel&#8221;</em></strong>. </p>



<p class="wp-block-paragraph">Then in action tag <em>start </em>the <strong>Apache</strong> and <strong>MySQL</strong>.</p>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="668" height="434" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/Annotation-2021-03-20-165436.png" alt="" class="wp-image-5698" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/Annotation-2021-03-20-165436.png 668w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/Annotation-2021-03-20-165436-300x195.png 300w" sizes="(max-width: 668px) 100vw, 668px" /></figure>



<p class="wp-block-paragraph">and then click on <strong><em>Admin</em></strong> of <strong><em>MySQl</em></strong>. It will redirect to<span class="has-inline-color has-black-color"> <em>http://localhost/phpmyadmin</em></span>.</p>



<ul class="wp-block-list"><li>Go to the database.</li><li>Give the name of the database and  click create.</li></ul>



<h3 class="wp-block-heading">Step 3: Connection to the database.</h3>



<p class="wp-block-paragraph">In the <strong><em>.env file </em></strong>of the Laravel folder(named crud in this blog) open it with VS Code. Change your code to this.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=gurukul
DB_USERNAME=root
DB_PASSWORD=
</pre></div>


<p class="wp-block-paragraph">where database name should be the same as you created in step2. and change DB_USERNAME to root.</p>



<h3 class="wp-block-heading">Step 4 : Migration of the table(From Laravel to MySQL Database)</h3>



<p class="wp-block-paragraph">We can make table in MySQL using the Laravel. For this we have to run this following command in cmd.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
php artisan make:migration create_crud_table –-create=crud
</pre></div>


<p class="wp-block-paragraph">You can use any name of your table instead of <em><strong>create_crud_table</strong></em>. The above command is going to create a migration(PHP file by the name of the table) file in the <strong>database/migration</strong> folder.</p>



<p class="wp-block-paragraph">Edit the code and paste this : </p>



<figure class="wp-block-image size-large"><img decoding="async" width="997" height="678" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/mig2.png" alt="" class="wp-image-5702" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/mig2.png 997w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/mig2-300x204.png 300w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/mig2-768x522.png 768w" sizes="(max-width: 997px) 100vw, 997px" /><figcaption><strong>update the function up()</strong></figcaption></figure>



<p class="wp-block-paragraph">Now in the command prompt use the following command : </p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
php artisan migrate
</pre></div>


<h2 class="wp-block-heading">Step 5: Create a Model File in Laravel </h2>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
php artisan make:model Crud -m
</pre></div>


<p class="wp-block-paragraph">In cmd, use this command to create the model file(You can use any name instead of <strong>Crud </strong>while making other projects)</p>



<p class="wp-block-paragraph">It will add a <em><strong>Crud.php </strong></em>file in the <strong><em>app </em></strong>folder and in this file in a variable define the table column.</p>


<div class="wp-block-syntaxhighlighter-code aligncenter"><pre class="brush: php; title: ; notranslate">
&lt;?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Crud extends Model
{
    //
    protected $fillable = &#x5B;
            &#039;first_name&#039;, &#039;last_name&#039;, &#039;image&#039;
        ];
}
</pre></div>


<h3 class="wp-block-heading">Step 6 : Creating the controller</h3>



<p class="wp-block-paragraph">Controller is used to handling the http request. They are stored in <strong>app/http/Controllers </strong>directory.</p>



<p class="wp-block-paragraph">We have to create the controller using the command line: </p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
php artisan make:model Crud -m
</pre></div>


<h5 class="wp-block-heading">Note : For making CrudController file in controllers </h5>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: php; title: ; notranslate">
php artisan make:controller CrudsController
</pre></div>


<h3 class="wp-block-heading">Step 7 : Setting the Route</h3>



<p class="wp-block-paragraph">Setting the route of all the CrudController class method in <strong><em>route/web.php</em></strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: php; title: ; notranslate">
Route::get(&#039;/&#039;, function () {
    return view(&#039;welcome&#039;);
});

Route::resource(&#039;crud&#039;, &#039;CrudController&#039;);
</pre></div>


<p class="wp-block-paragraph">This is very important method. </p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/crud-operations-in-laravel-php-framework/">CRUD OPERATIONS IN LARAVEL PHP FRAMEWORK</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/crud-operations-in-laravel-php-framework/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>CRUD Operation Detailed Explaination with Example.</title>
		<link>https://www.scmgalaxy.com/tutorials/crud-operation-detailed-explaination-with-example/</link>
					<comments>https://www.scmgalaxy.com/tutorials/crud-operation-detailed-explaination-with-example/#respond</comments>
		
		<dc:creator><![CDATA[abhishek k]]></dc:creator>
		<pubDate>Mon, 08 Mar 2021 13:12:48 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<category><![CDATA[Websites]]></category>
		<category><![CDATA[crud detail explaination]]></category>
		<category><![CDATA[crud examples]]></category>
		<category><![CDATA[crud explaination]]></category>
		<category><![CDATA[crud explanation with example]]></category>
		<category><![CDATA[crud operation in laravel]]></category>
		<category><![CDATA[laravel crud operations]]></category>
		<category><![CDATA[laravel crud operations examples]]></category>
		<category><![CDATA[steps to crud operation]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/?p=5446</guid>

					<description><![CDATA[<p>Before performing CRUD operations we need to do some of the basic tasks. These includes:- 1. Installing Laravel 2. Creating [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/crud-operation-detailed-explaination-with-example/">CRUD Operation Detailed Explaination with Example.</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Before performing CRUD operations we need to do some of the basic tasks. These includes:-                                                                                                                               <strong>1. Installing Laravel                                                                                                    2. Creating Laravel Project                                                                                       3. Making Model                                                                                                           4. Migrating</strong>                                                                                                                          After that we are good to go for the operation.</p>



<p class="wp-block-paragraph">Explanation for the above operations is given in link below <a href="https://www.scmgalaxy.com/tutorials/crud-operation-prerequisites/" data-type="URL" data-id="https://www.scmgalaxy.com/tutorials/crud-operation-prerequisites/">https://www.scmgalaxy.com/tutorials/crud-operation-prerequisites/</a></p>



<p class="wp-block-paragraph"><strong>5. Create Operation</strong></p>



<p class="wp-block-paragraph">Create a folder Under <strong><em>resource</em> </strong>=&gt;<em><strong>view</strong> </em>=&gt; <strong><em>Task</em></strong> =&gt;<strong><em>File_name</em> </strong> (say <strong><em>create.blade.php</em></strong>) and code the Html part in it.  </p>



<figure class="wp-block-image size-large is-resized is-style-default"><img decoding="async" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-21-1024x576.png" alt="" class="wp-image-5457" width="512" height="288" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-21-1024x576.png 1024w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-21-300x169.png 300w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-21-768x432.png 768w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-21-1536x864.png 1536w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-21.png 1920w" sizes="(max-width: 512px) 100vw, 512px" /></figure>



<p class="wp-block-paragraph">We will now move to route(<strong><em>web.php</em></strong>) and create a route for the view . We will use <em>Route::get(&#8216;create&#8217;,&#8217;TaskController@index&#8217;)-&gt;name(&#8216;create&#8217;);</em>                                                                    </p>



<p class="wp-block-paragraph"> We will now move to route(<strong><em>web.php</em></strong>) and create a route for the view to display.                                                                                                                                                                                                                                                                               name(&#8216;<strong>task</strong>&#8216;) is given in the URL as <strong>http://127.0.0.1:8000/task</strong>.                                                                                                                         Control flow:- As the URL is hit the control will go the route(<strong><em>web.php</em></strong>), there we will write                                                                                       <em>Route::get(&#8216;<em>create</em>&#8216;,&#8217;TaskController@create&#8217;)->name(&#8216;<em>create</em>&#8216;);</em>                                     Here, there will be a name match from the URL and if there is a match then there will be a function call named <strong>create</strong> and route will redirect to <em><strong>TaskController.php</strong></em> where it will find the function <em>create </em>and operate according to the instructions given in it. }            </p>



<script src="https://gist.github.com/abhi040498/0955ba05864a7c67b51e6d222ba6a7a3.js"></script>



<p class="wp-block-paragraph">The <em><strong>TaskController.php</strong></em> will get to the create function definition                                    Here this function will return a view <strong><em>create</em>.blade.php</strong>, which has html codes, Output displayed on the browser.                               </p>



<figure class="wp-block-image size-large is-resized is-style-default"><img loading="lazy" decoding="async" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-22-1024x576.png" alt="" class="wp-image-5458" width="512" height="288" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-22-1024x576.png 1024w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-22-300x169.png 300w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-22-768x432.png 768w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-22-1536x864.png 1536w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-22.png 1920w" sizes="auto, (max-width: 512px) 100vw, 512px" /></figure>



<p class="wp-block-paragraph">After the create operation we need to store the data in the database for this we used <strong><em>&lt;form action=&#8221;{{route(&#8216;store&#8217;)}}&#8221; method=&#8221;POST&#8221;></em></strong> which will call store function.  for that, we need to call the store function when the user clicks submit after entering the data on the above page.                                                     The store function be like                          </p>



<script src="https://gist.github.com/abhi040498/c57065a3124ffb12ff36e63334907604.js"></script>



<p class="wp-block-paragraph">In the store function we create object <strong>$var</strong> of <strong>Task </strong>make variables as      <strong>$var-&gt;task</strong>&nbsp;which is assigned&nbsp;<strong>$request-&gt;task;</strong>&nbsp;(gets value from 1<sup>st</sup> field) &amp; <strong>$var-&gt;detail </strong>which is assigned&nbsp;<strong>$request-&gt;detail;</strong>&nbsp;(gets value from 2<sup>nd</sup> field) and <strong><em>$var-&gt;save(); </em></strong>function will save it to the database.</p>



<p class="wp-block-paragraph">Soon after the data is created and stored in the database, we can view it by performing Read operation.</p>



<p class="wp-block-paragraph"><strong>6. Read operation</strong></p>



<p class="wp-block-paragraph">Create a file in <strong><em>resource</em> </strong>=&gt;<em><strong>view</strong> </em>=&gt; <strong><em>Task</em> </strong>(say, <strong><em>task.blade.php</em></strong>).                                                                                                              and code the Html part in it.       </p>



<figure class="wp-block-image size-large is-resized is-style-default"><img loading="lazy" decoding="async" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-19-1024x576.png" alt="" class="wp-image-5454" width="512" height="288" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-19-1024x576.png 1024w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-19-300x169.png 300w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-19-768x432.png 768w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-19-1536x864.png 1536w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-19.png 1920w" sizes="auto, (max-width: 512px) 100vw, 512px" /></figure>



<figure class="wp-block-image size-large is-resized is-style-default"><img loading="lazy" decoding="async" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-20-1024x576.png" alt="" class="wp-image-5455" width="512" height="288" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-20-1024x576.png 1024w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-20-300x169.png 300w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-20-768x432.png 768w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-20-1536x864.png 1536w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-20.png 1920w" sizes="auto, (max-width: 512px) 100vw, 512px" /></figure>



<p class="wp-block-paragraph">                                                                                                                                                                                                                            We will now move to route(<strong><em>web.php</em></strong>) and create a route for the view to display. We will write the name(&#8216;<strong>task</strong>&#8216;) is given in the URL as <strong>http://127.0.0.1:8000/task</strong>.                                                                                                                         Control flow:- As the URL is hit the control will go the route(<strong><em>web.php</em></strong>), there it will write                                                                                       <em>Route::get(&#8216;task&#8217;,&#8217;TaskController@index&#8217;)->name(&#8216;task&#8217;);</em>                                     Here, there will be a name match from the URL and if there is a match then there will be a function call named <strong>index</strong> and route will redirect to <em><strong>TaskController.php</strong></em> where it will find the function <em>index </em>and operate according to the instructions given in it. }                                                                                               </p>



<script src="https://gist.github.com/abhi040498/82d0d6f56f23cd533d386a93ec7b4682.js"></script>



<p class="wp-block-paragraph">Here this function will return a view taskIndex.blade.php, which has HTML codes, which is to display on the browser with all the things compact.   </p>



<figure class="wp-block-image size-large is-resized is-style-default"><img loading="lazy" decoding="async" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-18-1024x576.png" alt="" class="wp-image-5453" width="512" height="288" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-18-1024x576.png 1024w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-18-300x169.png 300w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-18-768x432.png 768w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-18-1536x864.png 1536w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-18.png 1920w" sizes="auto, (max-width: 512px) 100vw, 512px" /></figure>



<p class="wp-block-paragraph">  <strong>7. Update operation</strong></p>



<p class="wp-block-paragraph">Create a file in <strong><em>resource</em> </strong>=&gt;<em><strong>view</strong> </em>=&gt; <strong><em>Task</em> </strong>=&gt;<strong><em> File_name</em></strong> (say, <strong><em>edit.blade.php</em></strong>). and code the Html part in it.                                     </p>



<figure class="wp-block-image size-large is-resized is-style-default"><img loading="lazy" decoding="async" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-24-1024x576.png" alt="" class="wp-image-5460" width="512" height="288" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-24-1024x576.png 1024w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-24-300x169.png 300w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-24-768x432.png 768w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-24-1536x864.png 1536w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-24.png 1920w" sizes="auto, (max-width: 512px) 100vw, 512px" /></figure>



<p class="wp-block-paragraph"> For update we need to give an edit button which calls the update function when clicked. for this we used                                                                                                                       <em>&lt;a href=&#8221;{{route(&#8216;notes.edit&#8217;,[&#8216;id&#8217; => $note->id])}}&#8221;  type=&#8221;button&#8221; class=&#8221;btn btn-primary&#8221;>Edit&lt;/a></em>                                                      This will redirect to route (<strong><em>web.php</em></strong>) where we will write                                                      <em>Route::get(&#8216;edit&#8217;,&#8217;TaskController@edit&#8217;)->name(&#8216;edit&#8217;);</em>                                                                                                                                                   Here, there will be a name match from the URL and if there is match then there will be a function call named <strong>edit </strong>and route will redirect to <em><strong>TaskController.php</strong></em> where it will find the function <em>edit </em>and operate according to the instructions given in it.                                                                                                                                                                                                                                       This will call edit function                       </p>



<script src="https://gist.github.com/abhi040498/d6990b216eb841d8db35122c9fe11d72.js"></script>



<p class="wp-block-paragraph">This will find the corresponding <strong>id</strong> and return the edit page view with the details prefilled in it.    </p>



<figure class="wp-block-image size-large is-resized is-style-default"><img loading="lazy" decoding="async" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-23-1024x576.png" alt="" class="wp-image-5459" width="512" height="288" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-23-1024x576.png 1024w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-23-300x169.png 300w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-23-768x432.png 768w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-23-1536x864.png 1536w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/03/image-23.png 1920w" sizes="auto, (max-width: 512px) 100vw, 512px" /></figure>



<p class="wp-block-paragraph">On click of submitting after changing the details which were prefilled,                         This will redirect to route (web.php) where we will write    Route::post(&#8216;update/{id}&#8217;,&#8217;TaskController@update&#8217;)->name(&#8216;update&#8217;);         Here, there will be a name match from the URL and if there is a match then there will be a function call named <strong>update </strong>and route will redirect to <em><strong>TaskController.php</strong></em> where it will find the function <em>update </em>and operate according to the instructions given in it.                                                                                                The update function will run.                                                                                                                                </p>



<script src="https://gist.github.com/abhi040498/863a37e330a8c5ee7e016a3b8ab466ec.js"></script>



<p class="wp-block-paragraph"> In the Update function we create object <strong>$var1</strong> of <strong>Task </strong> which finds and matches id and make variables as <strong>$var1->task</strong> which is assigned                                             <strong>$request->task;</strong> (gets value from 1<sup>st</sup> field) &amp; <strong>$var1->detail </strong>which is assigned <strong>$request->detail;</strong> (gets value from 2<sup>nd</sup> field) and <strong><em>$var1->save(); </em></strong>function will save it to the database.                                                                               and <em><strong>return redirect()</strong></em>   will redirect the <em>route </em>to <em>task</em>.                                                                       </p>



<p class="wp-block-paragraph"><strong>7. Delete Operation</strong></p>



<p class="wp-block-paragraph">Implementing delete operation is easy and we need to Just provide a delete button in the html view which will help call the <strong>destroy </strong>function.                          </p>



<p class="wp-block-paragraph">On click of <strong>Delete </strong>button                                                                                                                          This will redirect to route (<strong><em>web.php</em></strong>) where we will write    <em>Route::post(&#8216;delete/{id}&#8217;,&#8217;TaskController@delete&#8217;)->name(&#8216;delete&#8217;);</em>                                                                                                                                                                                        Here, there will be a name match from the URL and if there is a match then there will be a function call named <strong>delete </strong>and route will redirect to <em><strong>TaskController.php</strong></em> where it will find the function <em>delete </em>and operate according to the instructions given in it.                                                                                                The update function will run.                                                                                                                                </p>



<script src="https://gist.github.com/abhi040498/a99c5418db1a2ee83030a4781866f52c.js"></script>



<p class="wp-block-paragraph">In the Update function we create object <strong>$var</strong>2 of <strong>Task </strong> which finds and matches id and <strong><em>$var1->delete(); </em></strong>function will delete it from the database.                                                                               and <em><strong>return redirect()</strong></em>   will redirect the <em>route </em>to <em>task</em>.                                                                       </p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/crud-operation-detailed-explaination-with-example/">CRUD Operation Detailed Explaination with Example.</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/crud-operation-detailed-explaination-with-example/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
