F
Filament9mo ago
Blaze

Activity logs can be seen by all roles

I just implemented filament logger by z3dox and it seems that the logs can be seen by all roles, how can i make it only viewable by Super Admins? Im using filament shield for the roles. Im also using Acitvity logger by Dennis Koch
Solution:
Gate::policy(Activity::class, ActivityPolicy::class);
Gate::policy(Activity::class, ActivityPolicy::class);
...
Jump to solution
7 Replies
Blaze
BlazeOP9mo ago
i tried it but it doesn't work i have generated the policy
krekas
krekas9mo ago
If you would show the code...
Blaze
BlazeOP8mo ago
this is my code
Vp
Vp8mo ago
Did you put like below in AppServiceProvider (assuming you are on L-11)?
Solution
Vp
Vp8mo ago
Gate::policy(Activity::class, ActivityPolicy::class);
Gate::policy(Activity::class, ActivityPolicy::class);
Blaze
BlazeOP8mo ago
<?php

namespace App\Providers;

use App\Models\Activity;
use App\Policies\ActivityPolicy;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}

/**
* Bootstrap any application services.
*/
public function boot(): void
{
Gate::policy(Activity::class, ActivityPolicy::class);
}
}
<?php

namespace App\Providers;

use App\Models\Activity;
use App\Policies\ActivityPolicy;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}

/**
* Bootstrap any application services.
*/
public function boot(): void
{
Gate::policy(Activity::class, ActivityPolicy::class);
}
}
should i put it like this? thanks its working

Did you find this page helpful?