Support the ongoing development of →
Eloquent Database Laravel
Last updated 1 year ago.


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:


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!


Sign in to participate in this thread!


Your banner here too?

guestisp guestisp Joined 17 Apr 2014


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

Your logo here?

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

© 2024 - All rights reserved.