Support the ongoing development of Laravel.io →
Eloquent Database Laravel
Last updated 8 months ago.
0

Hello,

I think you don't need any special name for your problem, in order to solve it, you can make a pivot table with the laravel convention:

author_publisher

With the two IDs of the author and the publisher as FK and the counter as extra pivot column.

So in your model (Author for example, but works also vice versa):

public function publishers()
{
    return $this->belongsToMany(Publisher::class)->withPivot('counter');
}

And when you associate the models, you can store the extra pivot data:

$author->publishers()->attach($publisher, ['counter' => $counter]);

Hope it helps!

0

Sign in to participate in this thread!

Cloudways

Your banner here too?

guestisp guestisp Joined 17 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2023 Laravel.io - All rights reserved.