Laravel package, simple functionality to set a user as admin without an advanced role system
mvd81/laravel-is-admin is a Laravel package for laravel package, simple functionality to set a user as admin without an advanced role system.
It currently has 1 GitHub stars and 189 downloads on Packagist (latest version 3.3).
Install it with composer require mvd81/laravel-is-admin.
Discover more Laravel packages by mvd81
or browse all Laravel packages to compare alternatives.
Last updated
Laravel package to extend your Laravel application with a simple admin permission functionality, with:
composer require mvd81/laravel-is-admin
Run
php artisan migrate
to create the 'is_admin' column in the users table
Import the trait in the User model
use Mvd81\LaravelIsAdmin\Traits\isAdmin;
class User extends Authenticatable
{
use isAdmin;
...
is_admin to the $fillable array in the User modelYou can set a 'normal' user as admin by setting the database column is_admin to 1 , in database table users.
Or in the code
$user = User::find(ID);
$user->makeAdmin();
$user = User::find(ID);
$user->undoAdmin();
It is possible to use user with ID 1 as admin without setting the 'is_admin' column to 1.
First you need to publish the config file.
php artisan vendor:publishNow in config/is_admin.php set 'use_super_admin' to true.
'use_super_admin' => true,
There is a IsAdmin middleware to use in your routes.
Example:
Route::get('admin-page')->middleware('IsAdmin');
Partial template/layout in your Blade view files only for admins?
You can use this Blade directive
@isAdmin()
I am an admin
@endisAdmin
You can enter an artisan command to see who is an admin.
php artisan user:who-is-admin
composer remove mvd81/laravel-is-adminconfig/is_admin.phpis_admin column in table users@isAdmin() directive, remove themis_admin middleware from your routes