Looking to hire Laravel developers? Try LaraJobs

laravel-permission maintained by almas

Description
A dynamic role and permission system designed to reduce development time.
Author
Last update
2025/11/11 15:54 (dev-main)
License
Downloads
10

Comments
comments powered by Disqus

A dynamic role and permission system designed to reduce development time. Fully compatible with Laravel Livewire. Support for React and other stacks is in progress.

Latest Version on Packagist Total Downloads

Installation

You can install the package via Composer:

composer require almas/laravel-permission

Set Super Admin Set the Super Admin email in your .env file:

SUPER_ADMIN_EMAIL=superadmin@gmail.com
  • If not defined, the default is superadmin@gmail.com.
  • A random password is automatically generated for the Super Admin.
  • You can reset the password via the "Forgot Password" option

After installation, run the following Artisan command to set up everything:

php artisan permission

This command will:

  • Run necessary database migrations
  • Seed default roles and permissions automatically

No additional setup is required — you're ready to go!

Publish Configuration File

To publish the configuration file for this package, run the following command:

php artisan vendor:publish --tag=permission-config

Super Admin Features

  • Only the Super Admin can create and delete permissions.
  • For every new permission added to the system, the Super Admin is automatically granted that permission.

Route Registration

Add the following line to your routes/web.php file:

use Illuminate\Support\Facades\Route;

Route::permission();
  • By default, all routes will be protected using the auth middleware.
  • This will automatically register all necessary permission management routes.

Route Prefix Behavior

  • When using Route::permission();, the base route will be:
{your-app-url}/permission
  • You can customize the base route prefix by passing a parameter to the Route::permission() method:
Route::permission('custom-prefix');
  • This will change the base route to:
{your-app-url}/custom-prefix

Blade Helper to Get Base Permission URL

@PermissionLink

Usage

  • Get All Permissions (as array):
user_permission()
  • Check a Single Permission: (eg. true/false):
user_permission('show-users')
  • Blade Directives:
@user_permission('show-users')
    <a>Show Users</a>
@end_user_permission

License

The MIT License (MIT). Please see License File for more information.