dimanche 13 mars 2016

How can I query a has-many-through relationship in Laravel

What are some ways to query this type of relationship in Laravel

Tables:

  • Users
  • Roles
  • Privileges

Where:

  • Each role has a set of privileges
  • Each user can belong to many roles
  • The User has many privileges through Roles
  • Users and Roles are related through an intermediate table. So there is no user_id column on the Roles table

In effect I'm trying to do something like:

User()->Roles()->Privileges()->get() 

but I'm not sure of the laravel way to do this



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire