Laravel 8 multi auth. Redirect users and admins to different pages. Using Laratrust authentication.
HTML-код
- Опубликовано: 13 июл 2024
- Github repo: github.com/Norbertho/Laravel-...
In this video I show how to create laravel 8 multi auth for users like Admin, User, Student, Teacher.... For this laravel 8 authentication I use Laratrust package. We show different page for admin and user, and show different menu for admin and for user. This multi auth system works with laravel 8 fortify, Laravel jetstream, and with LAravel Breeze. After the laravel admin and user login we redirect them to different pages. We using laravel roles and permissions as well.
My twitter: / norberthalase
00:00 Intro
02:42 Setup Laravel Breeze
05:38 Setup Laratrust package
12:22 How to assign rols to users like admin
20:09 How to create a controlller in laravel 8
34:30 How to protect routes for admin and for different type of users
#Laravel8MuliAuth #Laratrust #LaravelAuthentication Наука
HI, at the beginning of the tutorial, you say "it's work with jetstream..." I tried to run it with jetstream but there is no AUTH file in APP/HTTP/CONTROLLERS, could you please help me! Thank You
@@CodeFisher Thank you, but the small thing you forget App/Actions/Fortify/CreateNewUser.php. ;-)
@@CodeFisher can this concept apply to laravel vue js (I'm still new to laravel )
@@CodeFisher thanks a lot.
while using jetstream, how can I attach the roles? It does not let me use the `Request $request` variable in the CreateNewUser.php file
@@subodhpoudel6116 just paste this
user= User::create([
'name' => $input['name'],
'email' => $input['email'],
'password' => Hash::make($input['password']),
]);
$user->attachRole($input['role_id']);
Wow, thanks so much!! This is just that I needed, I spended a lot of time looking for how to implement that feature in my new site.
Your explaination is good because you assume the viewer is a beginner, worth to watch and like.
A very good tutorial. I finally understood how multiuser works in Laravel. I'm a beginner.
That is awesome. Very clear tutorial on multiAuth
Well explained. Thank you for this tutorial!!!
Amazing tutorial, very explicit. thanks a lot for this video
Hello and thanks for the video, it really helped me complete my project!! also I study in hungary and I immediately recognized that hungarian english accent lol, thanks again.
This video feels me professional. Thank you
sir thank you so much its very amazing and helpful i followed you step by step and impress my manger
Such a good tutorial!! Thank you :)
Adequate and sufficient explanation. ❤️
mmm
Merci, ça marche. Après avoir longtemps cherché, je suis tombé dessus et ça m'a vraiment aidé. Thank you !!!
Bonjour comment vous allez?
J'ai suivi exactement ce qu'il a fait mais j'ai un problème avec la methode 'hasRole'. On me dit que ce n'est pas défini
Svp aidé moi
Thank you !! It's help me a lot...
great tutorial!
Thanks for sharing this package
Thanks for your video
Pretty good video on this topic. I successfully completed it with no problems.
How? I am having problems with the hasRole method and I cannot define the route it gives me an error
Amazing tutorial, was very helpful to me.
Thanks.
Thank you very much, it worked perfectly, I subscribe for more 😁
Good job, thank you very much
Excellent
Thank You So Much🤗
Very good and usful tutorial. i am proud my child
thanks a lot sir
amazing content.
greate job
Thank you for this, although I have been coding this manually; I'll try this out.
please can you share how you code this manually!
great tutorial
very very very very very very very very very very very very very very very THANK YOU
thank you for tutorials, next time make tutorial CRUD with multi auth laravel 8
valuable video
You explain things well, it's a mess finding someone who doesn't assume you already know everything. By the way can you help me with an issue. I want to store a user id and use it in a condition to show and hide a menu. The menu will be included in four different views. I hope there will be more videos from you, you've earned yourself a subscriber and i'm certain it will be more
Dear,
Thanks for your well explain and a good tutorial.
1 this is more important for a Laravel projects which is moduleing system in Laravel 8, could you please, make a video for how to make a module structure in Laravel 8.
Thank you for this tutorial!!
You missed something in the protection, when the user choose his role he can just open the console and edit the value of any option in the select element and may be he will send an admin value and the admin route will be accessible for him.
helpfull
This also works with laravel ui guys if you want the same but using bootstrap instead, that was awesome for my project (sorry for my english if i said something wrong)
senk you so mats ,besto frendo
Thank you sir! I am pretty new in laravel but I have to create a system with this technology.
I have a question. In my DB I have to create teacher and students, they are different aspects and I have to create more tables which connect the relations between teachers and students. How can I manage these aspects using laratrust?
Nice video help me get pass my user control problem
Is there gonna be laravel 8 sanctum backend with vue js frontend tutorial video anytime soon?
Good work I was able to grab the concept I needed, but too many adverts, can't follow for even a minute.
Can I update the roles_structure after I added it to the database? Like if there's already there. Can I add more?
Also, what are those under superadministrator, administrator and user? The users,profile,payments. Can you explain? TIA.
Hi Can I ask you a question? I followed your instructions in both this video and the new one about Laravel Jetstream. I have set up vanilla Laravel Jetstream with TEAMS and also with EMAIL VERIFICATION. It is working. If I want to incorporate LaraTrust can I do this on top of vanilla Laravel Jetstream? I.e. I thought that TEAMS would supply a roles and permissions environment but I do not see the tables in my database. I tried spatie but I find your LaraTrust is much simpler. I do not want to break the vanilla Laravel Jetstream I have set up per above. But I do want to set up the ability to allow access to certain pages if admin and deny if user as you explained in this video.
So, you put logic in your view (if role is user do this, if role is blog do that)? but the model is MVC. Are you sure is the correct way following MVC ? And thanks for the video !
Hello, Mr @Code Fisher, I create a new user in the " jetstream " project they will not add any enters in the "role_user" table.
Is it possible to use Laratrust with bootstrap auth system?
Hi, what if my USER has more or different information than the ADMIN? In your case there is only table, both for user and admin.
Is there a way to have a table for the simple users and another one for the admins?
thanks this tutorial helps me a lot.., please can you make a tutorial on google authentication from scratch
superb so great sir... i love this video. basically if we want to assign more permission how to handle these type of permissions for spacific user. kindly could you help me?
at 20:01, where did u get the code for //auth route for both in web.php?
Hi , great video but is it possible you can do a version with laravel 8 with jetstream+ livewire ?
this is better
I using Laravel 8.35.1 and I did everything like in the movie
but my "hasRole" is undefined and I try to fix this but I can't find solution. Can You help me?
Very good explanation. Good teaching. I have one question. Can i install Admin LTE for this project ?
Thank you.
hello have you been able to integrate adminlte and laratrust authentication into laravel 8? If so, how? help me please
hi there after creating the different views and running the project i get a blank page
for all users
please upload next video to manage permissions from admin panel kindly
I will upload an updated version soon.
What if you also want to put the My profile on the blog page?
thank you . btw is it okay / applicable with basic auth ui ?
Yes u just nedd a minor changes on the register controller
THANKS SO MUCH FOR THIS TUTORIAL? AND WHAT DO WE DO IF WE WANT THE ADMIN TO APPROVE USERS?
Maybe my answer late , i think you can use status when user registered. Then admin will be approve/change status to approved
Please make a video of laravel8 and vue js components and redirect from one to other... Without run php artisan serve commamd..
Any crud solution in your tutorial?
hello thank u for the video
yes
@M J bro should i add the event(new Register($user));
?
I do not have the RegisteredUserController at 13:19 ? I am using laravel vue
hi brother,
i want to update Role.
ex-:(user update blogwriter)
how do this?
I have prblm in method hasRole, it is always undefinded !!
hello sir , hope you're doing fine .
i'm having this problem when i change the attachRole method to $request->role_id , when i try to add a user it gives me 404 not found. I can't find the problem.
how can you send user back on login page with exception (You don't have permission) if he didn't access of web?
hy sir i want to redirect different url for admin and user..in login time like for admin =admin/dashboard and user for user/dashboard
HasRole is undefined in vscode , pls help me
how to allow registration only to Admin after login as admin?
How to register without dropdown and using custom routes for admin and user ? could you please help me
@9:35: How does the users, payments and profile come handy? Does anyone have an example? How do I just show one user role?
how to fix sir I can still access the login route even though I'm already login
please how do i move my dashboard.blade.php to a different folder?
Hello, I follow all the steps, but laratrust does not install the seeder that you use.
how to add voyager admin panel in this authentication with laratrust? I have created multi auth now how can i add admin panel? please help
How I will do it if I don't use a php database just sqlite? where I store the data? I mena in factory? I am new with this laravel thing
how can i make that with jetstream
I lost the record from role_user table every times i have closed the program and run again. How is to fix it?
Can i use impersonate user. Login to other user without logout?
I have error in method hasRole() undefind how i can sole that ?
Add
$user = User::find(Auth::user()->id );
Then write
if ($user->hasRole('user')) {
return view('userdash');
}
hi, please i need to know how i can give "Register" only for admin
HELLO!
in the dashbordController you use "hasRole"
i do the same but i have a problem ??
Undefined method 'hasRole'.intelephense(1013)
1. In the User.php under "use Illuminate\Notifications\Notifiable;" add "use Laratrust\Traits\LaratrustUserTrait;"
2. Add "use LaratrustUserTrait;" at the beggining of "class User extends Authenticatable"
That should be it, if it doesn't work run "composer dump-autoload" and if then still doesn't work then check your database, if you have been changing something directly in "role_user" table (like i did) then you will lose all day for nothing :D
@@martisuper7963 And so we shouldn't register a user before using the hasRole method?
@@martisuper7963 i follow your instructions but it doesn't work
@@martisuper7963 oh come on, you are great, thank you
$user->attachRole($request->role_id);
already done this
then how to switch into the admin dashboard and how to register as a admin
please explain am a beginner....
hi, I just want to ask why Illuminate\Support\ facades\Auth isn't working?
The dashboard didn't showed up even though I type the exact codes you did. Hope you san help me!
please how can i use it on jetstream?
Can anyone guide me that in Laravel 8 after login where credentials passes to check whether the user is authorized or not?
i want to check weather it is Admin or User to redirect to their respective page.
I think its would be best to use middleware if its for routes. then it would be east to separate routes for admin, user, guest
if i want 4 blogwritter with different email and show different information for each in the same blogwritterdash??? please make a tutoral about this....
how to write to and read from database please
how to use laratrust without tailwind...??
how i crud user and copywriter in admin sir ?
how do i create a user from admin panel
i did same steps but i cant find auth in my controllers :(
No estoy en contra de los indios pero aleluya, por fin alguien que habla normal el ingles y que mejor que un nativo angloparlante... puff creo que el acento indio es un tanto desesperante, en serio
the siento bro
Hi, i got an undefined error when using hasRole method…need help
Add
$user = User::find(Auth::user()->id );
Then write
if ($user->hasRole('user')) {
return view('userdash');
}
sir can you please tell us how to set forget password in laravel 8
Thanks for this tutorial. How to integrate Laratrust authentication and AdminLTE dashboard templates in laravel 8, If you don't mind, can @Code Fisher be okay with making a tutorial like that? Thank you for helping.
hello have you been able to integrate adminlte and laratrust authentication into laravel 8? If so, how? help me please
hi i have an error Call to undefined method App\Models\User::attachRole()...can u help me?
@@CodeFisher no
hey man! thanks for the tutorial. in dashboardcontroller, i am getting an error saying hasRole() is not defined, any ideas on how to fix it?
i have the same error
Me too
1. In the User.php under "use Illuminate\Notifications\Notifiable;" add "use Laratrust\Traits\LaratrustUserTrait;"
2. Add "use LaratrustUserTrait;" at the beggining of "class User extends Authenticatable"
That should be it, if it doesn't work run "composer dump-autoload" and if then still doesn't work then check your database, if you have been changing something directly in "role_user" table (like i did) then you will lose all day for nothing :D
me too
@@martisuper7963 would you mind sharing what did you do then?