Z3d0X / filament-logger

Extensible activity logger for filament that works out-of-the-box.
MIT License
279 stars 40 forks source link

Allow to integrate/use Filament shield for roles and Permission #18

Closed MarJose123 closed 2 years ago

MarJose123 commented 2 years ago

Allow to add use HasPageShield; traits based on this documentation.

https://github.com/bezhanSalleh/filament-shield#pages

Z3d0X commented 2 years ago

Hi, filament-shield should already automatically pickup the ActivityResource from this package and generate permissions for it. However you'd need to manually hook up the policy generated by shield to spaites Activity Model Is this what you are asking or have i misunderstood the question?

MarJose123 commented 2 years ago

the policy generated by shield to spaites Activity Model is already in there but the Resource is still showing up.

Z3d0X commented 2 years ago

However you'd need to manually hook up the policy generated by shield to spaites Activity Model.

Since Activity Model is in a package laravel doesn't automatically pickup the policy for it Do this in your AuthServiceProvider and it should work

<?php

namespace App\Providers;

use Spatie\Activitylog\Models\Activity;
use App\Policies\ActivityPolicy;

class AuthServiceProvider extends ServiceProvider
{
    protected $policies = [
        Activity::class => ActivityPolicy::class, // <- add this
    ];

    public function boot()
    {
        $this->registerPolicies();
    }
}