Issue with search on relation & attribute as select name.

So i got a bit complicated select question:

                Forms\Components\Select::make('ram_id')
                    ->label('Ram')
                    ->relationship('ram', 'select_name')
                    ->required()
                    ->searchable( [ 'animals.country_code', 'animals.registration_number', 'animals.name' ] ),


I want to make an select field which has a relation with the ram relation (hasOne Animal). Where i can search the field based on country_code/registration_number/name. The 'select_name' is an attribute set in the model as followed:

    public function getSelectNameAttribute(): string {
        return $this->country_code . $this->registration_number . ' - ' . $this->name;
    }


But with the given code i get the following error, which makes sense but i don't really got a clue on how to solve it.

SQLSTATE[42703]: Undefined column: 7 ERROR: column "select_name" does not exist LINE 1: select "select_name", "id" from "animals" where ("animals"."... ^ (Connection: pgsql, SQL: select "select_name", "id" from "animals" where ("animals"."country_code"::text ilike %nhenk% or "animals"."registration_number"::text ilike %nhenk% or "animals"."name"::text ilike %nhenk%) order by "select_name" asc limit 50)
Was this page helpful?