Set table to use for Filament resource

ookma-kyi

Oct 31st, 2024 08:49 AM

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`

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?

Report
1
bobbyiliev

Nov 1st, 2024 02:22 AM

Hey!

I think that this issue happens because Filament auto-generates table names based on the model name and expects a standard naming convention.

You can try to explicitly define the table name in your model so that Filament uses model_has_roles as intended.

In your Model_Has_Roles model, set the table name manually:

protected $table = 'model_has_roles';

Let me know if this resolves the issue!

Report
1