-
I have this structure: class Place extends Model
{
public function discounts(): BelongsToMany
{
return $this->belongsToMany(Discount::class)->using(DiscountPlace::class);
}
}
class Discount extends Model
{
public function places(): BelongsToMany
{
return $this->belongsToMany(Place::class)->using(DiscountPlace::class);
}
}
class DiscountPlace extends Pivot
{
public $incrementing = true;
public function activities(): MorphMany
{
return $this->morphMany(Activity::class, 'subject', 'subject_type', 'subject_id');
}
} Why does calling If I call |
Beta Was this translation helpful? Give feedback.
Answered by
Cellard
Sep 24, 2025
Replies: 1 comment 4 replies
-
You should add |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
projct1
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should add
withPivot(["id"])
to belongsToMany