定制 luizfabianonogueira/acl-permissions 二次开发

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

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

luizfabianonogueira/acl-permissions

最新稳定版本:V0.1

Composer 安装命令:

composer require luizfabianonogueira/acl-permissions

包简介

ACL Permissions is a Laravel package that provides a robust and flexible access control system based on ACL (Access Control List). It allows you to define and manage permissions in a granular way for users and groups, ensuring that each resource is accessed only by those with proper authorization.

README 文档

README

Laravel Logo

ACL - Permisions

Latest Stable Version Total Downloads Latest Unstable Version License Static Badge

This package is a simple and easy way to manage permissions in Laravel applications.

Badge em Desenvolvimento

Installation

You can install the package via composer:

composer require luizfabianonogueira/acl-permissions

Configuration

In bootstrp/app.php add the following line:

use LuizFabianoNogueira\AclPermissions\AclPermissionsServiceProvider;

return [
    ...
    AclPermissionsServiceProvider::class,
    ...
];

You can publish the config file with:

php artisan vendor:publish --tag="acl-permissions-config"
php artisan vendor:publish --tag="acl-permissions-migrations"
php artisan vendor:publish --tag="acl-permissions-views"

This is the contents of the published config file:

return [

    /**
     * Define the column type of the id in user table.
     */
    'user_id_is' => 'UUID', # INTEGER or UUID

    /**
     * Define the column type of the id in user table.
     */
    'role_id_is' => 'UUID', # INTEGER or UUID

    /**
     * The user model that should be used to retrieve your permissions.
     */
    'user' => App\Models\User::class,

    /**
     * The role model that should be used to retrieve your permissions.
     */
    'role' => null
];

Extension UUID is available in Laravel 8.x \

Verify if the UUID is enabled in your database.

After publishing the config file and the migrations, run the migrations:

php artisan migrate

In your User model add the code below:

use LuizFabianoNogueira\AclPermissions\Models\Role;

    /**
     * Get the roles for the user.
     */
    public function roles(): BelongsToMany
    {
        return $this->belongsToMany(Role::class, 'role_user', 'user_id', 'role_id');
    }

In AppServiceProvider.php add the code below:

use LuizFabianoNogueira\AclPermissions\Services\AclPermissionService;

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        AclPermissionService::registerGates();
    }

In Bootstrap/app.php add the code below:

use LuizFabianoNogueira\AclPermissions\Http\Middleware\ACLPermissions;

return Application::configure(basePath: dirname(__DIR__))
    ->withRouting(
        web: __DIR__.'/../routes/web.php',
        commands: __DIR__.'/../routes/console.php',
        health: '/up',
    )
    ->withMiddleware(function (Middleware $middleware) {
        $middleware->alias([
            'acl-permissions' => ACLPermissions::class
        ]);
    })
    ->withExceptions(function (Exceptions $exceptions) {
        //
    })->create();

In app/Http/Controllers/Auth/LoginController.php add the code below:

use LuizFabianoNogueira\AclPermissions\Services\AclPermissionService;

    /**
     * @return string
     */
    public function redirectTo(): string
    {
        AclPermissionService::loadPermissions();
        return $this->redirectTo;
    }

Usage

To access the permissions screen, access the url below:

https://[urlofyoursystem]/acl-permissions/permissions/list

img.png

Permissions

On this screen, you can create, edit, and delete permissions. Permissions are used to control access to the application's routes. There are two ways to use permissions: \

  • URL, which is done through middleware comparing the route name with the permission name. In this case, you should pay attention to the route name structure. \
  • Gates or the user interface. @can

Users

On the users screen you can just link the roles.

Roles

On the roles screen you can create, edit and delete roles. Then you can add permissions to roles. Roles are used to control access to application routes.

License: LGPL-3.0-or-later

Contact & Support

LinkedIn WhatsApp GitHub Packagist

📞 Phone: +5548991779088
✉️ Email: luizfabianonogueira@gmail.com

Support My Work

If you enjoyed this project and would like to support my work, any donation via Pix is greatly appreciated!
Feel free to donate using one of the following Pix keys:

💳 Email Pix Key: luizfabianonogueira@gmail.com
📱 Phone Pix Key: 48991779088

Thank you for your support!

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: LGPL-3.0-or-later
  • 更新时间: 2024-10-04