<?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>rishav, Author at scmGalaxy</title>
	<atom:link href="https://www.scmgalaxy.com/tutorials/author/rishav/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.scmgalaxy.com/tutorials/author/rishav/</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>
	</channel>
</rss>
