I don't think i want to do authorization like this, because not everyone may have permissions set like this..
Since filament resources respects model policy, you can restrict access by using a policy for Activity Model.
Here is an example:
//App/Policies/ActivityLogPolicy.php
<?php
namespace App\Policies;
use App\Models\User;
class ActivityLogPolicy
{
public function viewAny(User $user): bool
{
return $user->can('view_activity');
}
public function view(User $user): bool
{
return $user->can('view_activity');
}
}
then in your AuthServiceProvider you can hook up Activity Model & ActivityLogPolicy
<?php
namespace App\Providers;
use App\Policies\ActivityLogPolicy;
use Spatie\Activitylog\Models\Activity;
class AuthServiceProvider extends ServiceProvider
{
protected $policies = [
Activity::class => ActivityLogPolicy::class,
];
//other stuff
}
I don't think i want to do authorization like this, because not everyone may have permissions set like this..
Since filament resources respects model policy, you can restrict access by using a policy for
Activity
Model. Here is an example:then in your
AuthServiceProvider
you can hook upActivity
Model &ActivityLogPolicy