Select relationship
hello on my case my relation between User and Company is one to many "company HasMany users" on my code i can gate companies without users on the creation but when i edit i want also add on my select the company of the user
this is my current code :
Select::make('company_id')
->relationship('company', 'name',fn (Builder $query)
=> $query
->whereDoesntHave('users' )
)
![](https://utfs.io/f/6978bdd8-e82e-4f4b-90e2-1e956f256374-zhdl0n.png)
![](https://utfs.io/f/93305f95-9d5a-4d57-b8cb-aa18977d1a58-veyavp.png)
2 Replies
i thing somthing like that :
->relationship('company', 'name',fn (Builder $query)
=> $query
->whereDoesntHave('users' )
->orWhereHas('users', function($query) {
return $query->where('companies.id', '=', 'company_id');
}
))
how can access to company_id on the form
search “dependant selects” in the docs
you can use $get(‘company_id’)