Call to undefined method BelongsToThrough::associate()

Hi, I am new here so sorry if i don't do all the steps right. I have 3 models, City, Zone, Country A city belongs to a zone and a zone belongs to a country I am trying to create a city add form since Laravel is not offering support for BelongsToThrough i pulled in the staudenmeir/belongs-to-through (as recomandate in Filamentphp documentation). All is ok on view and list, but on update and create i have this error Znck\Eloquent\Relations\BelongsToThrough::associate(), and this is normal since the BelongsToThrough dosen't have the associate() function on it. my form has this inputs/selects:
Select::make('country_id')
->label(__('country_name'))
->relationship('country', 'name')
->options(Country::all()->pluck('name', 'id')->toArray())
->reactive()
->rules('required')
->afterStateUpdated(fn (callable $set) => $set('zone_id', null)),

Select::make('zone_id')
->label(__('zone_name'))
->relationship('zone', 'name')
->options(function (callable $get) {
$country = Country::find($get('country_id'));
if (!$country) {
return [];
}
return $country->zones->pluck('name', 'id');
})
->rules('required'),

TextInput::make('name')
->label(__('city.name'))
->rules('required|min:3|max:255')
->placeholder(__('city.name'))
->columnSpanFull(),
Select::make('country_id')
->label(__('country_name'))
->relationship('country', 'name')
->options(Country::all()->pluck('name', 'id')->toArray())
->reactive()
->rules('required')
->afterStateUpdated(fn (callable $set) => $set('zone_id', null)),

Select::make('zone_id')
->label(__('zone_name'))
->relationship('zone', 'name')
->options(function (callable $get) {
$country = Country::find($get('country_id'));
if (!$country) {
return [];
}
return $country->zones->pluck('name', 'id');
})
->rules('required'),

TextInput::make('name')
->label(__('city.name'))
->rules('required|min:3|max:255')
->placeholder(__('city.name'))
->columnSpanFull(),
Has anyone run into this problem ? How did you fix it ? Thank you!
5 Replies
raya
raya13mo ago
Hello, i have the same problem. Can anyone else fix it... 😩
krekas
krekas13mo ago
pay money if you want someone to "fix it" for you
raya
raya13mo ago
pay to whom? can you help me?
bionary
bionary11mo ago
@KodyXgen @raya Did you guys ever figure this BelongsToThrough::associate() error out yet? I'm struggling with this one.
misaf
misaf11mo ago
in select.php of forms/src/Components/ add below code: if ($relationship instanceof \Znck\Eloquent\Relations\BelongsToThrough) { return; }
Want results from more Discord servers?
Add your server