F
Filament16mo ago
Pasteko

Is there any way chain relations with ->relationship?

Is it possible?
9 Replies
Mark Chaney
Mark Chaney16mo ago
yes, you do something like
Group::make()
->relationship('publisher')
->schema([
TextInput::make(...)
->relationship('author')
....
Group::make()
->relationship('publisher')
->schema([
TextInput::make(...)
->relationship('author')
....
something like that at least basically you can drill down that way. seems a bit hackish, but works
Pasteko
Pasteko16mo ago
Is it possible with something like that :
->relationship('product', 'year_id',
fn (Builder $query) => $query->with('year')->where('id', 'year_id'))
->relationship('product', 'year_id',
fn (Builder $query) => $query->with('year')->where('id', 'year_id'))
Dan Harrin
Dan Harrin16mo ago
whats the goal
Pasteko
Pasteko16mo ago
I need to have 5 or more dependent selects.
Pasteko
Pasteko16mo ago
First I have successfully implemented the instructions in this video : https://www.youtube.com/watch?v=W_eNyimRi3w But I wanted a solution without loading every model, only accessing data trough relations, now I'm stuck with only the 1st select working.
Dan Harrin
YouTube
Dependant Select Inputs - Filament TALL Stack Form Builder
This video, we are using the filament/forms package. You can read the full documentation at: https://filamentadmin.com/docs/forms You can find out more about Filament on our website: https://filamentadmin.com Follow me on Twitter for more tutorials and other TALL stack tips: https://twitter.com/danjharrin If you found this video useful, pleas...
Dan Harrin
Dan Harrin16mo ago
->with('year') is for eager loading and wont scope anything you probably just need $get to access the value of a different select
Pasteko
Pasteko16mo ago
Is there any example of dependent selects trough relations? Is it possible or not?
Dan Harrin
Dan Harrin16mo ago
its possible but i dont have time to write the code for you
Pasteko
Pasteko16mo ago
No problem, your help was already precious. Is it possible to write this that way?
$annee = Canton::with('produit.annee')->find($get('produit.annee_id'));
$annee = Canton::with('produit.annee')->find($get('produit.annee_id'));