mohit / usertype
Laravel User types - Admin/User
Requires
- php: ^7.0
- illuminate/database: 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.*
- illuminate/support: 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.*
Requires (Dev)
- phpunit/phpunit: ^6.4
This package is auto-updated.
Last update: 2025-06-29 00:50:06 UTC
README
This package create user types like Simple user, Admin and Super Admin.
Installation
You can install the package via composer:
composer require mohit/usertype
php artisan vendor:publish --provider="mohit\usertype\UsertypeProvider"
php artisan migrate
Create Admin User
php artisan create:admin
It will ask you to enter name, email and password. Then you can login with entered email and password.
Create Super Admin User
Super Admin user have roles of accessing admin pages as well as user pages.
php artisan create:super
It will ask you to enter name, email and password. Then you can login with entered email and password.
Usage
This package creates and registeres new middleware which you can use in routes file. You can assign middleware to either group of routes or individual routes.
For admin,
Route::group(['middleware' => 'authorize:admin'], function(){ // });
For user,
Route::group(['middleware' => 'authorize:user'], function(){ // });
For super admin,
Route::group(['middleware' => 'authorize:admin|user'], function(){ // });
Using In Blades
@if(auth()->user()->type == 'admin') // @endif
Styling Unauthorized page
When any user try to access page for which he is not authorized then it will redirect him to unauthorized page. This page follow bootstrap structure. You can style this page by creating new css file under 'public/css/unauthorized.css'.