Z3d0X/filament-logger

Allow to integrate/use Filament shield for roles and Permission

Closed this issue · 3 comments

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

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

Z3d0X commented

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?

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

Z3d0X commented

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();
    }
}