Answer the question
In order to leave comments, you need to log in
How to implement a relationship through a table in Laravel?
I'm trying to get caracteristics with relations to product_mod_characteristics.
Now for this I do this:
class ProductMod {
public function characteristics(): HasMany
{
return $this->hasMany(ProductModCharacteristic::class);
}
public function getCharacteristics(): array
{
$characteristicsId = $this->characteristics()
->select('characteristic_id')
->distinct()
->pluck('characteristic_id')
->toArray();
/**
затем запрашиваю caracteristics со связью к product_mod_characteristics
*/
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question