search

Home  >  Q&A  >  body text

Ask a question about related query in laravel

is a many-to-many association.

// 三个表如下
users   user_role   roles

Now I want to query the name field of all roles

to which all users belong.

How to use Eloquent ORM to write this related query?


solved. .

User::with('roles')->get();
淡淡烟草味淡淡烟草味2755 days ago371

reply all(1)I'll reply

  • 黄舟

    黄舟2017-05-16 16:57:10

    It seems that permission verification needs to be written. It is recommended to use the entrust package. Address: https://github.com/Zizaco/ent...

    reply
    0
  • Cancelreply