HasManyThrough for select field

Hello, Select field is not compatible with HasManyThrough ? Any way to make it work? i have
public function categorii()
{
return $this->hasManyThrough(Categorii::class, NecesareCategorii::class, 'id_necesar', 'id', 'id', 'id_categorie');
}
public function categorii()
{
return $this->hasManyThrough(Categorii::class, NecesareCategorii::class, 'id_necesar', 'id', 'id', 'id_categorie');
}
But in my select field when I select and save the record, doesn't seems to be creating the relation
1 Reply
jamesro
jamesroOP2mo ago
solved by changing relation to belongsToMany, hope is correctly:
public function categorii()
{
return $this->belongsToMany(Categorii::class, 'necesare_categorii', 'id_necesar', 'id_categorie');
}
public function categorii()
{
return $this->belongsToMany(Categorii::class, 'necesare_categorii', 'id_necesar', 'id_categorie');
}
Want results from more Discord servers?
Add your server