How to use Laravel backpack for non admin user - laravel

In my system, there are tow types of users.
Admin.
Regular.
For admin I am using Laravel backpack. But, I also want the backpack's features for non admin panel also.
What's the way?

Usually people use Roles/Permissions to handle that.
There is a Backpack addon that will give you a kick start with cruds for user/permission/role using the Spatie Laravel Permission under the hood: https://github.com/Laravel-Backpack/PermissionManager
Then you can show some bits of your app to some users, hide some fields/columns from others etc.
Just remember that users will be authenticating using backpack guard, so you should use backpack_user()->hasRole(), or see the advanced configuration of the package in ReadMe.
Cheers

Related

How To Make Laravel Admin Approval

im new to laravel. i want to make an admin panel with multiple role, and any role except admin that trying to CRUD, must need Admin approval to implement it. is there any library, or tutorial how to do it, please i need it to learn.
Thanks
You could try the Spatie Permissions package:
https://spatie.be/docs/laravel-permission/v3/introduction
The features you could look at to learn this are Laravel's Gates and Policies, which can be used to restrict access based on criteria.
https://laravel.com/docs/8.x/authorization

Laravel Admin with controller level permissions

what I want to create is Laravel 5.2 Admin and there are around 200 users who will use it with different permissions, so you can say 200 roles with different permissions.
I was planning to eliminate the role part from the picture and create some slug based mechanism, slugs will be related to controller public functions in short routes.
In Admin panel superuser will be able to assign permissions to user on controller functions with slugs.
Is this possible with any existing laravel package currently? If not then what will be the optimal solution you guys propose.
I always use Spatie Package, it is very flexible. You can manage role & permissions or only permissions. It is full of functions that make it easy. Check the documentation.
spatie-laravel-permission

login as a user and admin at the same time in laravel

I am working on a laravel project in which from ADMIN panel I can log in in the user module, but when I want to go back from the browser the admin panel is not working means admin is logout. is there any method in which I can log in in both module admin and user.
If you log in as one user, you log out as the other.
I see 2 possibilities:
1) Make 2 user tables, with separate login/logout/etc. one for your frontend users, one for your admin panel.
The advantage here is that your regular users will never be able to login as an admin, because they don't exist in that table.
2) Separate your frontend and admin panel into 2 different projects. You can link them to the same database. Put the admin panel on a subsite admin.my-project.com.
The advantage here is that you seperate your logic between 2 projects, each focused on different functionality, with their own styling, layout and most important for your example: authentication.
Use an incognito browser window for your admin tasks, which will enable you to be logged in to the same app twice.
You could solve your problem with two possible ways that laravel provide and you could google about "laravel multi auth example".
Multiple authentications using "middleware"
Multiple authentications using auth "guards"
Here are two articles will help you to understand and show you the implement with an example:
Laravel 6 Multi Auth (Authentication) Tutorial
How to use multiple authentication guards in a Laravel app

User and admin role in laravel 5.3

In my laravel project, I want some admin and user role. I want to make user login in different routes after login. And also for admin also. How should I do it?
You should first make 3 table in your database; user, role and user_role. user_role table has many to many relationship. Then you will make a middleware that checks your role checks when login. In your route, you use that middleware in login's post.
See details about middle ware in laravel 5.3 documentation.
https://www.laravel.com/docs/5.3/middleware
You can try laravel 5.3 boilerplate. It comes with a full featured access control system out of the box with an easy to learn API and is built on a Twitter Bootstrap foundation with a front and backend architecture.

Headstart needed for re-using the register functionality in Laravel 5.0

I am building a Laravel 5.0 project. With this the admin section is only accessible for registered users. I have added for example a user type to the User model and want to create and edit users using an admin module instead of the standard registration form in /auth/register.
But I cannot seem to find how to disable /auth/register for the outside world, but also cannot create my own CRUD for managing users.
So my main two questions are:
How can I reuse the password encryption in my own create and update functionality
How can I disable /auth/register for the not logged in users?
Thanx in advance

Resources