Mysql
 sql >> Base de données >  >> RDS >> Mysql

Eloquent many-to-many-to-many - comment charger facilement une relation distante

Voici comment procéder :

User::where('id', $id)->with(['groups.permissions' => function ($q) use (&$permissions) {
     $permissions = $q->get()->unique();
}])->first();

// then
$permissions; // collection of unique permissions of the user with id = $id