Manish Champaneri
Manish Champaneri

Reputation: 652

How to create multiple pivot tables for the same two models in laravel?

I have to models User & Article

User can like Article & User can bookmark article

if i create a pivot than it will be same for both user_article pivot

Can any one help ?

Upvotes: 1

Views: 1192

Answers (1)

Alexey Mezenin
Alexey Mezenin

Reputation: 163898

Just define another relationship in these models and add custom pivot table name:

public function anotherRelationship()
{
    return $this->belongsToMany('App\Article', 'another_pivot_table_name');
}

Upvotes: 3

Related Questions