How to make a readonly role?

Hey! I would like to make a readonly role for my users on Filament panel. I created my RO policy, linked the models to it.
<?php

namespace App\Policies;

use App\Models\User;

class ReadonlyPolicy
{
public function create(User $user): bool
{
return !$user->role->isReadonly();
}

public function delete(User $user): bool
{
return !$user->role->isReadonly();
}

public function update(User $user): bool
{
return !$user->role->isReadonly();
}
}
<?php

namespace App\Policies;

use App\Models\User;

class ReadonlyPolicy
{
public function create(User $user): bool
{
return !$user->role->isReadonly();
}

public function delete(User $user): bool
{
return !$user->role->isReadonly();
}

public function update(User $user): bool
{
return !$user->role->isReadonly();
}
}
Everything is working great, a little too good in my opinion. When users clicks on a model link on Filament, they get a 403 Forbidden error which is expected, but not all details are on the table. Is there a way to let them access the "edit" page without allowing them to edit the entry on the DB?
1 Reply

Did you find this page helpful?