I’m using filament and spatie laravel permissions for roles(only for roles, it’s not my decision). When I’m trying to make Select in form like this:
Select::make('roles.name')
->relationship('roles', 'name')
->options(RoleType::class)
->required(),
I’m encountering the error:
SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type bigint: “writer” CONTEXT: unnamed portal parameter $3 = ‘…’ (Connection: pgsql, SQL: insert into “model_has_roles” (“model_id”, “model_type”, “role_id”) values (2, user, writer))
My enum:
enum RoleType: string implements HasLabel
{
case Writer = 'writer';
case User = 'user';
public function getLabel(): ?string
{
return __('enums/role_type.' . $this->value);
}
}
Also I’m using casts in Role model (via enum). I spent like 4 hours to solve this problem, but I can’t solve it. Also, when I’ve asked my mentor(I’m laravel intern) he said that I can’t use getStateUsing, options(list them all) e.t.c
Help me pls
P.S. php 8.3, laravel 11.30, filament 3.2, laravel-permission 6.10
I tried to use chatGPT to solve this problem, but he just used getStateUsing or options that I shouldn’t use.