In this Video I Will Show How You Can Achieve Constructor Injection with Reference Type In Spring Java
Introduction 00:00
Example Start 00:45
Command for Installing Npm Server and nodeModules in Project
npm install --dev-save vite laravel-vite-plugin
Command for Running Npm Server
npm run dev
Command for Migrate tables in Database
php artisan migrate
Command for Migrate Users in Database
php artisan db:seed
Login Controller
protected function login(Request $request)
{
$credentials = $request- validate([
'email' = 'required|email',
'password' = 'required',
]);
if(Auth::attempt($credentials)){
$user_role=Auth::user()- role;
switch($user_role){
case 1:
return redirect('/channcelor');
break;
case 2:
return redirect('/dean');
break;
case 3:
return redirect('/professor');
break;
case 4:
return redirect('/lecturer');
break;
case 5:
return redirect('/instructor');
break;
default:
Auth::logout();
return redirect('/login')- with('error','oops something went wrong');
}
}else{
return redirect('login')- with('error','The credentials do not match our records');
}
}
Channcelor Middleware Code
public function handle(Request $request, Closure $next): Response
{
if(!Auth::check())
{
return redirect()- route('login');
}
$user = Auth::user();
if($user- role==1)
{
return $next($request);
}
if($user- role==2)
{
return redirect()- route('dean');
}if($user- role==3)
{
return redirect()- route('professor');
}if($user- role==4)
{
return redirect()- route('lecturer');
}if($user- role==5)
{ return redirect()- route('instructor');
}
}
DISCLAIMER: This channel does not promote or encourage any illegal activities, all contents provided by this channel is meant for educational purpose only,
Video Editor : Afnan Guides
Copyright Disclaimer :- Under Section 107 of the Copyright Act 1976, allowance is made for fair use for purposes such as criticism, comment, news reporting, teaching, scholarship, and research. Fair use is a use permitted by copyright statute that might otherwise be infringing. Non-profit, educational or personal use tips the balance in favor of fair use.
-This video is for educational purpose only.
🔹️THANKS FOR WATCHING THIS VIDEO....!!!! 👇
. I hope this video will be helpful to you.
Best of Luck....!