Set table to use for filament resource

I am trying to use Filament with Laravel Permissions and have run into an issue. I set the model relationship manually protected static ?string $model = Model_Has_Roles::class; as that's what the table is called. However when I try to access it I get the following error:
QLSTATE[42S02]: Base table or view not found: 1146 Table 'ookma-kyi.model__has__roles' doesn't exist

select count(*) as aggregate from `model__has__roles`
QLSTATE[42S02]: Base table or view not found: 1146 Table 'ookma-kyi.model__has__roles' doesn't exist

select count(*) as aggregate from `model__has__roles`
It seems Filament added an additional _ between each word as it should be model_has_roles. I tried to search the documentation but, didn't find anything at the time. Could someone please steer me in the right direction?
8 Replies
Bruno Pereira
Bruno Pereiraβ€’5d ago
In the model class try putting
protected $table = 'model_has_roles';
protected $table = 'model_has_roles';
As you can see, the project is trying to access
model__has__roles instead of model_has_roles
model__has__roles instead of model_has_roles
.
Ookma-Kyi Project Leader
Uh, it's still stuck, it seems the model_has_roles table doesn't have an id column.
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'model_has_roles.id' in 'order clause'

select * from `model_has_roles` order by `model_has_roles`.`id` asc limit 10 offset 0
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'model_has_roles.id' in 'order clause'

select * from `model_has_roles` order by `model_has_roles`.`id` asc limit 10 offset 0
No description
Ookma-Kyi Project Leader
More bad news πŸ˜΅β€πŸ’«
No description
Bruno Pereira
Bruno Pereiraβ€’5d ago
Without any code I can't help you. What are you trying to do exactly? if thats the pivot table of a many to many relation, do you have the relations well defined? do you have a model called model? it's a polymorphic?
Ookma-Kyi Project Leader
Just create a simple resource to the model_has_roles table which is what Laravel Permission (https://spatie.be/docs/laravel-permission/v6/introduction) uses to assign roles to users
Ookma-Kyi Project Leader
No idea, I am using the default configuration of Laravel Permission
Bruno Pereira
Bruno Pereiraβ€’5d ago
I never used that package, I can't help further.
Ookma-Kyi Project Leader
Ok thanks anyways
Want results from more Discord servers?
Add your server