lloricode/filament-spatie-laravel-permission-plugin

This is my package filament-spatie-laravel-permission-plugin

v1.1.2 2024-11-11 00:43 UTC

This package is auto-updated.

Last update: 2024-11-11 00:44:20 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Requirements

Pre-requisite

To be able to use this package, you need to have spatie/laravel-permission v6.9+ installed. Then follow the installation guide of spatie/laravel-permission.

This has used a wildcard permission based. So you must to set this on your config/permission.php file, else it will throw an exception Please enable wildcard permission in your config/permission.php.

// config/permission.php
'enable_wildcard_permission' => true,

Installation

You can install the package via composer:

composer require lloricode/filament-spatie-laravel-permission-plugin

You can publish the config file with:

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

This is the contents of the published config file:

https://github.com/lloricode/filament-spatie-laravel-permission-plugin/blob/main/config/filament-permission.php

Usage

use Lloricode\FilamentSpatieLaravelPermissionPlugin\FilamentPermissionPlugin;

->plugins([
    FilamentPermissionPlugin::make(),
])

Setting up user model

// ...
use Lloricode\FilamentSpatieLaravelPermissionPlugin\Concern\PermissionUser;
use Lloricode\FilamentSpatieLaravelPermissionPlugin\Contracts\HasPermissionUser;

class Admin extends Authenticatable implements HasPermissionUser // ...
{
    use PermissionUser;
// ...

Setting up Filament pages

// ...
use Lloricode\FilamentSpatieLaravelPermissionPlugin\Concern\PermissionPages;
use Lloricode\FilamentSpatieLaravelPermissionPlugin\Contracts\HasPermissionPages;

class MyPage extends Page implements HasPermissionPages
{
    use PermissionPages;
// ...

Setting up Filament widgets

// ...
use Lloricode\FilamentSpatieLaravelPermissionPlugin\Concern\PermissionWidgets;
use Lloricode\FilamentSpatieLaravelPermissionPlugin\Contracts\HasPermissionWidgets;

class MyWidget extends ChartWidget implements HasPermissionWidgets
{
    use PermissionWidgets;
// ...

Finally, run this command to generate the permission.

php artisan permission:sync

Testing

composer test

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.