where("id", Auth::user()->company_id)->orWhere('parent_id', Auth::user()->company_id)->pluck("id"); return fn (Builder $query) => $query->whereIn('company_id', $company->toArray()); } 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.'); } } ]; } }