一对多关联表,怎么判断返回关联数组不为空的值啊?
User表
id、name、phone、created_at、updated_at
Role表
id、title、created_at、updated_at
user_role关联表
id、user_id、role_id
$users = User::with(['roles' => function ($query) {
$query->where();
}])
->orderBy('id', 'desc')->paginate(14);
想查询出有角色的用户,这个条件应该怎么写啊?
$query->where();
本作品采用《CC 协议》,转载必须注明作者和本文链接
推荐文章: