© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•14mo ago•
1 reply
hrvzmndz

cant hide depending on the role in my policy

Hi how can i hide the activity log depending on the role of the user?

i tried in appserviceprovider.php but no luck.


activitypolicy.php

<?php

namespace App\Policies;

use App\Models\Activity;
use App\Models\User;
use Illuminate\Auth\Access\Response;

class ActivityPolicy
{
/
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->isEditor();
}

/

* Determine whether the user can view the model.
*/
public function view(User $user, Activity $activity): bool
{
return $user->isEditor();

}

appserviceprovider.php

?php

namespace App\Providers;
use Filament\Facades\Filament;
use Illuminate\Support\ServiceProvider;
use Filament\Navigation\NavigationItem;
use App\Policies\ActivityPolicy;
use Spatie\Activitylog\Models\Activity;

class AppServiceProvider extends ServiceProvider
{
protected $policies = [
// Update
Activity::class
Activity::class
with the one defined in
config/activitylog.php
config/activitylog.php

Activity::class => ActivityPolicy::class,
];
/**
image.png
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How to hide dashboard from "Dashboard" depending on user role?
FilamentFFilament / ❓┊help
16mo ago
Dropdown access depending on role
FilamentFFilament / ❓┊help
3y ago
Is there a way to hide the whole navigation panel depending on role?
FilamentFFilament / ❓┊help
2y ago
Hide all resources depending on user
FilamentFFilament / ❓┊help
3y ago