samedi 25 août 2018

How to create relationship in Laravel 5 which will collect records of own model mentioned in pivot table?

I have 3 tables users, companies and pivot table with user_id, company_id. I can't get users, which belongs to my company inside User model. Tried like

belongsToMany('App\User','companies_users','company_id','user_id' );

but I get relation with wrong users.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire