承接 tiagolemosneitzke/filamentacl 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

tiagolemosneitzke/filamentacl

最新稳定版本:v1.1.0

Composer 安装命令:

composer require tiagolemosneitzke/filamentacl

包简介

A flexible and lightweight Access Control List (ACL) plugin for managing user permissions and roles in Laravel applications

README 文档

README

A flexible and lightweight Access Control List (ACL) plugin for managing user permissions and roles in Laravel applications using Filament.

Attention

This package doesn't work with Tenancy.

Latest Version on Packagist Total Downloads Packagist License

You can install the package via composer:

composer require tiagolemosneitzke/filamentacl -W

This will install the Filament ACL package along with its dependencies, including spatie/laravel-permission.

After the installation, publish the migration and configuration files:

php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"

Run the migrations to create the necessary tables:

php artisan migrate

Add the HasRoles trait to your User model:

use Spatie\Permission\Traits\HasRoles;

class User extends Authenticatable
{
    use HasRoles;
}

Register the plugin in your Panel provider:

use TiagoLemosNeitzke\FilamentAcl\FilamentAclPlugin;
 
public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
             FilamentAclPlugin::make()
        ]);
}

You can then install the Filament ACL package with the following command:

php artisan filament-acl:install

This will publish the config file.

Alternatively, you can publish only the config file with:

php artisan vendor:publish --tag="filament-acl-config"

This is the contents of the published config file:

return [
    'permission' => [
        'prefixes' => [
            'view',
            'view_any',
            'create',
            'update',
            'restore',
            'delete',
            'force_delete'
        ]
    ],

    'roles_prefixes' => [
        'admin',
    ]
];

Also, you can publish manually all the files with:

php artisan vendor:publish --provider="TiagoLemosNeitzke\FilamentAcl\FilamentAclServiceProvider"

Or you can publish the necessary files one by one

php artisan vendor:publish --tag=filament-acl-config
php artisan vendor:publish --tag=filament-acl-stubs

You don't need to publish all the files for the package work, but you need to publish the settings file and configuring correctly the Laravel Permissions Package.

In your UserResource file, you should add the below code to edit and view the permission of the user:

use TiagoLemosNeitzke\FilamentAcl\Models\Role;

public static function form(Form $form): Form
    {
        return $form
            ->schema([
                Forms\Components\Select::make('roles')
                    ->label('Role')
                    ->relationship('roles', 'name')
                    ->options(Role::all()->pluck('name', 'id'))
                    ->multiple()
                    ->preload()
                    ->searchable(),
            ]);
    }

    public static function table(Table $table): Table
    {
        return $table
            ->columns([
                Tables\Columns\TextColumn::make('roles.name')
                    ->label('Is Admin?')
                    ->badge(),
             ]);
    }

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-06