Laravel: Separate Admin/User Areas - Designs, Routes, Permissions
HTML-код
- Опубликовано: 19 окт 2024
- How do you separate the designs and the routes for administrator users and "front" users of your system?
In this video, we will have an example that covers 4 things:
Visual design/Blade
Route groups and URL prefixes
Redirect after login to their own area
Middleware/permissions: protect the admin area from access by simple users
Repo: github.com/Lar...
- - - -
Try our Laravel QuickAdminPanel: bit.ly/quickad...
Enroll in my Laravel courses: laraveldaily.t...
The most underrated channel. Surprised by the quality of content.
The quality is beyond belief
You can also create gates and then apply them in your routes:
Gate::define('Admin', function ($user) {
return $user->category == "admin";
});
Route::get('/', HomeController@index)->middleware('can:Admin');
A simplier way to do it.
Great Video!
Can you help me for my project ? Pleeeeeas
I like this approach. In the framework I'm using I extended the default login driver and added a column type in user table and added a method to login driver that checkes the user type, like that:
Auth::isClient();
It has worked well for me. I will test laravel soon, i've watched some videos about and it seems very productive to me.
Hello Povilas. Have I mentioned that every time when I get my head cracking on something silly but needed for a project, I can ALLWAYS rely on your Laravel Daily channel to achieve the simplest and most secure approach for a fully working profile.
I can't thank you enough for that and I can't understand why your channel is so UNDERRATED when you should have millions of people profiting from the skills and knowledge you share with such a passion and ease!
Thanks for the kind words, glad to help!
@@LaravelDaily Please make laravel 9 version of this soonest
U make the best direct understandable easy videos
Thank you😭😭😭 i needed this for a project
You are awesoooome!!!
I was getting stuck creating a Real Estate projects because I'm using Jetstream for Admin but I was lost when I was to create the User's area
As a beginner I understood 100%. Thanks
Great tutorial with fully function repo. Thank you so much brother
appreciating your videos. I want to see laravel testing video series, Unit ,feature and acceptance testing. Please make video on that also.
For Spatie Laravel Permission your can use this:
if (auth()->user()->hasAnyRole(['super-admin', 'admin'])) {
....
}
or hasRole('admin')
on which route or controller or view
Thanks
Great videos Povilas, I don't miss any :)...Would be very interesting to see a video (even a course) about permissions/roles with separate tables in DB. A table for regular users and a table only for admins.
Thanks for your kind words! To be honest, I would never personally recommend to have two separate tables, it's a pain to maintain then, you then need to have two separate auth systems. Anyone who logs into the system is a USER, so they need to use the same Laravel Auth and login mechanism. And then their roles/permissions should be defined in other tables or packages. My overall take on Roles/Permissions is in this course: laraveldaily.teachable.com/p/practical-roles-and-permissions-in-laravel
Important thing very well explained.
I don't know what is better: your Laravel sklills or your communication skills?
That's great..I am very much impressed with your skills... Incredible...
Thank you sir !
Thank you, this is exactly what i wanted to do.
Nice and to the point!
How can redirect to a different page using thelaravel breez and Spatie permission package?..(admin,user)
Hi, could you please increase the font size in your videos? I'm on 1080 and it's still blurry. I know my eyes aren't too good, I don't really want to overstrain them. Thank you. + what is app http kernel?
Thank you very much, man!!!!!!!!!!1
Hello thank you so much for posting and helping us with your extra ordinary knowledge. I would like to make a request please. Can you make a video or tutorial about the strategy for multiple user roles which has access to their child and grand child data please?
Can you rephrase with a specific example of what is "data" and what are "child" and "grand child", any real-life practical example? Then I would think if it's worth a separate tutorial.
Like a CRM user tree.
I haven't worked with such projects, need more details
@@LaravelDaily I will share the proper details today as this method is being used in ERP and CRM softwares and web apps also in multi vendor system, thank you.
Please check your email, I have sent the details.
Is this bad practice though? Since you're forcing it to a specific role? Like what if I add "managers", I would have to recode and add everything that I added for admin and user right?
Very good master, i like it
thank u soo muchh
Could you make a video about the repository design pattern in Laravel? Have been reading quite a bit about it but every writer has their own approach. With every article there are many comments about what is wrong and good about the provided examples. However there doesn't seem to be a general idea about what a good repository design pattern looks like.
I've talked about Repositories in my course: "How to Structure Laravel Project" - I've just made this lesson public for free, so you can watch here - laraveldaily.teachable.com/courses/how-to-structure-laravel-project/lectures/8760335 - and maybe enroll in full course.
In quickadminpanel how i do is i create permission access_adminpanel and on login redirect page if i see if role has admin panel access it redirects to admin panel. I do it because in future i may need user or other roles to access some part of admin panel. through quickadminpanel i have to just assign through roles and permissions rather than editing redirecto function.
I would prefer pivot and belongs to many. It makes code a lot cleaner and it does not require complex logic to perform multiple role based auth.
Could you pls suggest what is the best way to manage user login/register/role/permissions?
I have this video about it: ruclips.net/video/kZOgH3-0Bko/видео.html
So I shouldn't use Make:Auth for User area after I created Jetstream auth for Admins right?
can we use more than one middleware in backpack for laravel, if yes then can you make a video/tutorial for this one? or if you already made the tutorial, can you paste the url here. I need it. thank you sir
thank you very helpful ,but i have some problem haw can i prevent admin to access '/user' link ?
There is a issue how to solve this
if you have login with user account, and you go see home URL (project3.test) gives you 403 with project3.test/admin route
I think It should be redirect with project3.test/user if the user logined in.
But in case of admin it works well!
is it possible to do this if there are multiple user types?
thank you
how can I do it Fortify?
i have middleware, layouts and routes etc but now I do not have Auth Login controller. So where should I handle the redirects as per user type? Waiting for your guidenes. Thanks
Well i found a way by creating a responses directory and create LoginResponse class with toResponse method in it. Please share your thoughts on this approach.
thanks
That's sound great
The question is how to separate entirely the admin section in your laravel app, if the user tape for exemple /admin/dashboard this route should be hidden , i think the solution is to make sub domains .
Is it ok to have one shared public folder for site and admin areas?
Yes
i have run this project how do i get register page in this project for register new admin
can I use this for laravel 8?
4:20 i can't find the difference between using redirectPath and authenticate methods in LoginController
Great tutorial. Was wondering if u could do a video on having a sub account tied to the main account where they can share resources. E.g if u have a system where the main user account has some sort of points or let's say money in their account, they can create a sub account which they can allow the sub accounts to spend their money, or allow a specific portion of the money to them and once its finish they can contact certain actions because they don't have money.
Also the sub user or account should be able to view its own report. Maybe user can toggle between main accounts and sub accounts. Thank you
How to customize user menu.. We have admin menus at layouts.menu but what about user
What if I have two different tables? for example users for admins , and students table for student type of user?
this is my problem since my other type of user have a another relationship with another table so having a separate table aside from admin would be great
Is it possible to enter Controller in Http/Controller with route::group namespace club?
I use few controllers with simalarie methods for user and club.
Thank you
Sorry I didn't understand the question. All Controllers of Laravel are in Http/Controllers. I guess the only answer to your question is "try and see if it works".
Povilas Korop i have the Group Namespace set of Club.
Laravel errors tells me, when i try to call the method in my controller, that there is no controller in http/controller/club.
My for example „shootingbook“ controllers is under http/controller.
As anwork around i have add my routes for auth:club not in the „group club“ routes function
@@magic1708 Without debugging the full project, I can't really answer what is the best solution. If you found a workaround, then great.
Respect...
what is login credentials
I am not big fan of packages. So I just create myself with custom guard
im having touble acessing the register page
Im using permission to prevent the users with different roles
I use a similar approach, but I place my admin routes y a separate admin.php file and I use web.php for regular users.
how?
@@kenjohnsiosan9707 In RouteServiceProvider, you'll see how they include web.php
@@TheMessixaviniesta thank you sir
On same widow without logout any
Here I suggest choosing an admin panel for your Laravel project: ruclips.net/video/UCIlU1DAYus/видео.html
these videos are old, you maybe should refresh them with laravel 10
I will probably wait until Laravel 11 cause they promise major skeleton changes there, don't want to reshoot again.