$query->where('company_id', Auth::user()->company_id); } protected function usersCompanyRules(): array { return [ 'array', function ($attribute, $value, $fail) { $userCount = User::where("company_id", Auth::user()->company_id)->whereIn('id', $value)->count(); if ($userCount != count($value)) { $fail('The selected user is invalid.'); } } ]; } }