public function scopeRoleAcl($query, $groupIds, $authOptionId) { $roleIds = model_pluck(AuthRole::where(['auth_setting' => 1, 'auth_option_id' => $authOptionId]), 'role_id'); return $query->where(['auth_setting' => 0])->whereIn('auth_role_id', $roleIds)->whereIn('group_id', $groupIds); }