定制 almas/laravel-permission 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

almas/laravel-permission

最新稳定版本:1.0.0

Composer 安装命令:

composer require almas/laravel-permission

包简介

A dynamic role and permission system designed to reduce development time.

README 文档

README

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.

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: Blade

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-23