<?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>Sushanto Singh, Author at scmGalaxy</title>
	<atom:link href="https://www.scmgalaxy.com/tutorials/author/sushantodev/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.scmgalaxy.com/tutorials/author/sushantodev/</link>
	<description>A Platform for Software Engineers</description>
	<lastBuildDate>Wed, 24 Mar 2021 09:34:45 +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>Using Role Based Authentication, Create Different Users DashBoard</title>
		<link>https://www.scmgalaxy.com/tutorials/using-role-based-authentication-create-different-users-dashboard/</link>
					<comments>https://www.scmgalaxy.com/tutorials/using-role-based-authentication-create-different-users-dashboard/#respond</comments>
		
		<dc:creator><![CDATA[Sushanto Singh]]></dc:creator>
		<pubDate>Mon, 22 Mar 2021 12:59:35 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<category><![CDATA[laravel]]></category>
		<category><![CDATA[Php]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/?p=5714</guid>

					<description><![CDATA[<p>Prerequisite: i. Create a project in C:/xamp/htdocs directory by using Git Bash. To create a new project run the following [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/using-role-based-authentication-create-different-users-dashboard/">Using Role Based Authentication, Create Different Users DashBoard</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph" style="font-size:25px"><strong>Prerequisite</strong>:</p>



<p class="wp-block-paragraph"><em><strong>i.</strong></em> Create a project in C:/xamp/htdocs directory by using Git Bash. To create a new project run the following code in Git Bash terminal</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
composer create-project --prefer-dist laravel/laravel project_name &quot;5.8.*&quot;
</pre></div>


<p class="wp-block-paragraph"><em><strong>ii.</strong></em> Open the project in your  code editor like VS Code</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong><em>Step-1 </em></strong>: To use User Authentication in your project run the following code in code editor terminal</p>


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


<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong><em>Step-2</em></strong> :&nbsp;Customize users table to add role field in the table. Go to <strong>database/migration/2021_03_20_000000_create_users_table.php</strong>  and make some changes in users table.</p>



<script src="https://gist.github.com/SushantoSingh/5913750b67b4531d9f74933197e93d83.js"></script>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong><em>Step-3:</em></strong> Create a Role Model and Migration for Role Table by using the following code:</p>


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


<p class="wp-block-paragraph"> </p>



<p class="wp-block-paragraph"><strong><em>Step-4:</em></strong> Now customize the Role table and add role_id and role_name field .Go to <strong>database/migration/2020_03_20_060108_create_roles_table</strong> and make some changes in up() function.</p>



<script src="https://gist.github.com/SushantoSingh/5856ac193551c138df4c3527b80c8f27.js"></script>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong><em>Step-5</em></strong>: Make Relationship between Users and Roles tables through Role Model and User Model.</p>



<p class="wp-block-paragraph"><strong><em>i.</em></strong> To create relationship make changes in users( ) function in Role.php.</p>



<script src="https://gist.github.com/SushantoSingh/1919814036da6d0c0852e8694e12b813.js"></script>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong><em>ii. </em></strong>In User.php make a role( ) function and write the following code .</p>



<script src="https://gist.github.com/SushantoSingh/28344e1b75fe29904e4df89269fd4c7b.js"></script>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong><em>Step-6</em></strong> : &nbsp;Create&nbsp;<strong>UsersTableSeeder</strong>&nbsp; and <strong>RolesTableSeeder</strong> file  by writting following two command in terminal.</p>


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

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


<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong><em>Step-7:</em></strong>  Add Insert function in UsersTableSeeder.php and RolesTableSeeder.php file for Insert data in&nbsp;<strong>users</strong>&nbsp;table and <strong>role</strong> table. Add &#8221; <strong>use&nbsp;Illuminate\Support\Facades\DB; </strong>&#8221; in use area.</p>



<p class="wp-block-paragraph"><strong><em>i.</em></strong> Go to<strong> database/seeds/UsersTableSeeder.php</strong>  and add the following insert operation in run( ) function :</p>



<script src="https://gist.github.com/SushantoSingh/a6b312b8975252fb4f3d82e275a0aa90.js"></script>



<p class="wp-block-paragraph"><strong><em>ii. </em></strong>Go to<strong> database/seeds/RolesTableSeeder.php</strong> and add the following insert operation in run( ) function :</p>



<script src="https://gist.github.com/SushantoSingh/7cc9900156f526479ad66da72c5393da.js"></script>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong><em>Step-8 :</em></strong> Create a new Database and link it with the project</p>



<p class="wp-block-paragraph"><strong><em>i.</em></strong> Run Apache and MySql .</p>



<p class="wp-block-paragraph"><strong><em>ii. </em></strong>Open <strong><a href="http://localhost/phpmyadmin/">phpmyadmin/localhost</a></strong> in your web browser.</p>



<p class="wp-block-paragraph"><strong><em>iii. </em></strong>Create a new database and set its name.</p>



<p class="wp-block-paragraph"><strong><em>iv.</em></strong> Set Mysql Server Username ,Password and Database Name in<strong>&nbsp;.env</strong>&nbsp;file </p>



<p class="wp-block-paragraph">    DB_CONNECTION=mysql<br>    DB_HOST=127.0.0.1<br>    DB_PORT=3306<br>    DB_DATABASE=multipleuser (Your DB name)<br>    DB_USERNAME=root<br>    DB_PASSWORD=</p>



<p class="wp-block-paragraph"><strong><em>v. </em></strong>Migrate it by following command:</p>


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


<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong><em>Step-9 :</em></strong> Insert data in the table</p>


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


<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong><em>Step-10:</em></strong> Create&nbsp;<strong>DashboardController</strong>&nbsp;for Admin Dashboard work and User<strong> </strong>Dashboard&nbsp;work.</p>



<p class="wp-block-paragraph"><strong><em>i.</em></strong> For Admin Dashboard</p>


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


<p class="wp-block-paragraph"><strong><em>ii.</em></strong> For User Dashboard</p>


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


<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong><em>Step-11 :</em></strong>&nbsp;Make&nbsp;<strong>AdminMiddleware</strong>&nbsp;and <strong>UserMiddleware</strong> for Admin&nbsp;and User Authentication&nbsp;work.</p>



<p class="wp-block-paragraph"><strong><em>i. </em></strong>For AdminMiddleware</p>


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


<p class="wp-block-paragraph"><strong><em>ii.</em></strong> For UserMiddleware</p>


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


<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong><em>Step-12:</em></strong> Go to <strong>app/Http</strong> directory and  Use<strong>&nbsp;Auth</strong>&nbsp;class for Authentication in&nbsp;<strong>AdminMiddleware.php</strong> and <strong>UserMiddleware.php</strong> in use section. Implement  the following condition in handle( ) function:</p>



<p class="wp-block-paragraph">i. In <strong>AdminMiddleware.php</strong> add the following codition:</p>



<script src="https://gist.github.com/SushantoSingh/ecbf30adf9c2eb08f55b0dac38593739.js"></script>



<p class="wp-block-paragraph">i. In <strong><strong>UserMiddleware.php</strong></strong> add the following codition:</p>



<script src="https://gist.github.com/SushantoSingh/50b04820f49d195010303aa6be0f650f.js"></script>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong><em>Step-12:</em></strong> Go to <strong>app/Http/Middleware/RedirectIfAuthenticated.php</strong> . Implement Condition for&nbsp;<strong>Admin</strong>&nbsp;and&nbsp;<strong>User</strong>&nbsp;Login in <strong>RedirectIfAuthenticated.php</strong>. and not forget to put &#8221; <strong>use Auth;</strong> &#8221; in use section.</p>



<script src="https://gist.github.com/SushantoSingh/945590dea6a321d5f0152fb127c5dd9b.js"></script>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong><em>Step-13:</em></strong> Go to <strong><strong>app/Http/Controllers/Auth/</strong></strong> directory and remove&nbsp;<strong>= ‘/home’</strong>&nbsp;from protected&nbsp;<strong>$redirectTo = ‘/home’;</strong> for <strong>ResetPasswordController.php</strong> and <strong>LoginController.php</strong> . Implement Condition&nbsp;<strong>Login</strong> in both  php file in <strong>__construct( )</strong>  function.</p>



<p class="wp-block-paragraph"><strong><em>i.</em></strong> In <strong>LoginController.php</strong></p>



<script src="https://gist.github.com/SushantoSingh/f4dccf6727f0e4adb8a7bed7f627deab.js"></script>



<p class="wp-block-paragraph"><strong><em>ii.</em></strong> In <strong>ResetPasswordController.php</strong></p>



<script src="https://gist.github.com/SushantoSingh/405415edc6e3c63bc622a98f59547579.js"></script>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong><em>Step-14</em>.A : </strong> Use <strong>AdminMiddleware</strong> and&nbsp;<strong>UserMiddleware</strong>&nbsp;in&nbsp;<strong>Kernel.php</strong>&nbsp;File in <strong>app/Http/Kernel.php</strong> directory</p>



<p class="wp-block-paragraph">i. For <strong>AdminMiddleware</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
use App\Http\Middleware\AdminMiddleware;
</pre></div>


<p class="wp-block-paragraph">ii. For <strong>UserMiddleware</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
use App\Http\Middleware\UserMiddleware;
</pre></div>


<p class="wp-block-paragraph"><strong><em>Step-14.B :</em></strong> Define&nbsp;<strong>AdminMiddleware</strong> and <strong>UserMiddleware</strong> in&nbsp;<strong>routeMiddleware</strong></p>



<p class="wp-block-paragraph">i. For <strong>AdminMiddleware</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
&#039;admin&#039; =&gt; AdminMiddleware::class,
</pre></div>


<p class="wp-block-paragraph">ii. For <strong>UserMiddleware</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
use App\Http\Middleware\UserMiddleware;
</pre></div>


<script src="https://gist.github.com/SushantoSingh/3d4cdc571ad7e24558e0f717d270a4a3.js"></script>



<p class="wp-block-paragraph"></p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/using-role-based-authentication-create-different-users-dashboard/">Using Role Based Authentication, Create Different Users DashBoard</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/using-role-based-authentication-create-different-users-dashboard/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>CRUD Operation Using Laravel</title>
		<link>https://www.scmgalaxy.com/tutorials/crud-operation-using-laravel/</link>
					<comments>https://www.scmgalaxy.com/tutorials/crud-operation-using-laravel/#respond</comments>
		
		<dc:creator><![CDATA[Sushanto Singh]]></dc:creator>
		<pubDate>Sat, 20 Mar 2021 09:10:48 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/?p=5681</guid>

					<description><![CDATA[<p>CRUD is an short form for&#160;Create,&#160;Read,&#160;Update, and&#160;Delete. Using this operation users can easily manipulate the data. To preform CRUD operation [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/crud-operation-using-laravel/">CRUD Operation Using Laravel</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="has-vivid-purple-color has-text-color wp-block-paragraph"><strong><em>CRUD is an short form for&nbsp;Create,&nbsp;Read,&nbsp;Update, and&nbsp;Delete. Using this operation users can easily manipulate the data.</em></strong></p>



<p class="wp-block-paragraph"><em>To preform CRUD operation we have to preform certain steps </em>:</p>



<p class="wp-block-paragraph"></p>



<p class="has-vivid-purple-color has-text-color wp-block-paragraph"><em><strong>Step 1 : Make a new Project</strong> </em>.</p>



<p class="wp-block-paragraph"><em>To create a new project, run the following code in Git Bash in <strong>C:/xamp/htdocs</strong> Folder:</em></p>



<p class="has-black-color has-text-color wp-block-paragraph">composer create-project &#8211;prefer-dist laravel/laravel project_name “version_name.*”</p>



<p class="has-black-color has-text-color wp-block-paragraph"><em>Eg: </em>composer create-project &#8211;prefer-dist laravel/laravel  Employees &#8220;5.8.*&#8221;</p>



<p class="wp-block-paragraph"><em>It will automatically install all the necessary file and folder for you.</em></p>



<p class="wp-block-paragraph"></p>



<p class="has-vivid-purple-color has-text-color wp-block-paragraph"><em><strong>Step 2 : Create a Database in SQL</strong></em></p>



<p class="wp-block-paragraph"><em>Run Xamp Controller and start Apache and MySQL</em>.</p>



<p class="wp-block-paragraph"><em>Search localhost/phpmyadmin in your browser</em></p>



<p class="wp-block-paragraph"><em>Create a new database using  MySQL by simply click in New button and give your database a unique name.</em></p>



<p class="wp-block-paragraph"></p>



<p class="has-vivid-purple-color has-text-color wp-block-paragraph"><strong><em>Step 3 : Modify the Database connection in .env File</em></strong></p>



<p class="wp-block-paragraph"><em>Open the .env file and change database name and set username to &#8220;root&#8221;.</em></p>



<p class="wp-block-paragraph">DB_CONNECTION=mysql</p>



<p class="wp-block-paragraph">DB_HOST=127.0.0.1</p>



<p class="wp-block-paragraph">DB_PORT=3306</p>



<p class="wp-block-paragraph">DB_DATABASE=  <em>your database name</em></p>



<p class="wp-block-paragraph">DB_USERNAME=<em>you username(Default: root)</em></p>



<p class="wp-block-paragraph">DB_PASSWORD=</p>



<p class="wp-block-paragraph"></p>



<p class="has-vivid-purple-color has-text-color wp-block-paragraph"><em><strong>Step 4: Link the project with database</strong></em></p>



<p class="wp-block-paragraph"><em>To link  database  run the following command on Command Promt/Git Bash/Vs Code Terminal:</em></p>



<p class="wp-block-paragraph">php artisan migrate </p>



<p class="wp-block-paragraph"></p>



<p class="has-vivid-purple-color has-text-color wp-block-paragraph"><em><strong>Step 5: Create Table in database</strong></em></p>



<p class="wp-block-paragraph"><em>We are going to create crud application for product. so we have to create migration for “products” table using Laravel 5.8 php artisan command</em></p>



<p class="wp-block-paragraph">php artisan make:migration create_products_table –create=products</p>



<p class="wp-block-paragraph"></p>



<p class="has-vivid-purple-color has-text-color wp-block-paragraph"><strong><em>Step 6: Migration</em></strong></p>



<script src="https://gist.github.com/SushantoSingh/78b02c0146d3af7f18d46fa216d9dd00.js"></script>



<p class="wp-block-paragraph"></p>



<p class="has-vivid-purple-color has-text-color wp-block-paragraph"><strong><em>Step 7: Create Blade File</em></strong></p>



<p class="wp-block-paragraph"><em>Go to Project_name/resources/views and create the following file:</em></p>



<p class="wp-block-paragraph"><strong><em>i . parent.blade.php</em></strong></p>



<script src="https://gist.github.com/SushantoSingh/c18c4ffda88cb4a43bebe1c63e88ae36.js"></script>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong><em>ii. create.blade.php</em></strong></p>



<script src="https://gist.github.com/SushantoSingh/92e495ea88483d9735af824c9191db24.js"></script>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong><em>iii. view.blade.php</em></strong></p>



<script src="https://gist.github.com/SushantoSingh/b47a12bb26d6b773467bd8114cef4fa0.js"></script>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">i<strong><em>v. edit.blade.php</em></strong></p>



<script src="https://gist.github.com/SushantoSingh/dc7cca063ad8d0252d599c1ab11735ee.js"></script>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><em><strong>v. index.blade.php</strong></em></p>



<script src="https://gist.github.com/SushantoSingh/2f856e77c3824846087b3c546b0a9a0a.js"></script>



<p class="wp-block-paragraph"></p>



<p class="has-vivid-purple-color has-text-color wp-block-paragraph"><strong><em>Step 9 : Set Route </em></strong></p>



<p class="wp-block-paragraph"><em>Go to Project_name/route/web.php</em> <em>add the following code to change the route</em> <em>to universal route</em></p>



<script src="https://gist.github.com/SushantoSingh/26d6a1e97f7e336b1a0277f0273c6df5.js"></script>



<p class="wp-block-paragraph"><em>We can easily change the route by changing the route name. </em></p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/crud-operation-using-laravel/">CRUD Operation Using Laravel</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-using-laravel/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
