$modules = Role::with(['rights' => function ($q) {
return $q->with('module');
}])->where('id', $user->role_id)->get();
有人可以帮助解决这个问题吗?
你不能在with()
封闭内部的关系内返回。
相反,你可以使用Nested Eager Loading。
$modules = Role::where('id', $user->role_id)
->with('rights.module')
->get();