user()->can('create', Project::class); } public function rules() { $rules = []; //$rules['name'] ='required|unique:projects,name,null,null,company_id,'.auth()->user()->companyId(); $rules['name'] = 'required'; $rules['client_id'] = 'required|exists:clients,id,company_id,'.auth()->user()->company()->id; return $rules; } protected function prepareForValidation() { $input = $this->all(); if (array_key_exists('client_id', $input) && is_string($input['client_id'])) { $input['client_id'] = $this->decodePrimaryKey($input['client_id']); } $this->replace($input); } }