Rian
Rian
FFilament
Created by Rian on 3/3/2025 in #❓┊help
Multiple resources using same model not working
Hello! I've got a User model, with an attribute usertype, values 1=Admin, 2=User, 3=Worker. This works, initially I had a single resource to manage these. I've been trying to split it into separate resources, i.e.: AdministratorResource, UserResource, and WorkerResource. However, no matter what I change or try all three of the resources end up showing the users. I've tried creating a separate Administrator model, I've added an override for the EloquentQuery:
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()->withoutGlobalScopes()->with(['usertype' => UserType::Administrator]);
}
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()->withoutGlobalScopes()->with(['usertype' => UserType::Administrator]);
}
As well as in the table function:
public static function table(Table $table): Table
{
return $table
->modifyQueryUsing(fn (Builder $query) => $query->where('usertype', [UserType::Administrator->value]))
->columns([
......
public static function table(Table $table): Table
{
return $table
->modifyQueryUsing(fn (Builder $query) => $query->where('usertype', [UserType::Administrator->value]))
->columns([
......
No matter what I try, change, or do, all three of my resources show the same, breadcrumbs also show Users > list , rather than the relevant info from the resource I'm trying to view. At this point I have:
UserResource -> User::class
WorkerResource -> User::class
AdministratorResource -> Administrator::class
UserResource -> User::class
WorkerResource -> User::class
AdministratorResource -> Administrator::class
Where Administrator extends the User model, it was just an attempt to provide the resource with a different model. What am I doing wrong?
3 replies