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' )
)
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’)