user()->can('edit', $this->expense); } public function rules() { /* Ensure we have a client name, and that all emails are unique*/ $rules['country_id'] = 'integer|nullable'; //$rules['id_number'] = 'unique:clients,id_number,,id,company_id,' . auth()->user()->company()->id; $rules['contacts.*.email'] = 'nullable|distinct'; if ($this->input('number')) { $rules['number'] = 'unique:expenses,number,'.$this->id.',id,company_id,'.$this->expense->company_id; } return $this->globalRules($rules); } public function messages() { return [ 'unique' => ctrans('validation.unique', ['attribute' => 'email']), 'email' => ctrans('validation.email', ['attribute' => 'email']), 'name.required' => ctrans('validation.required', ['attribute' => 'name']), 'required' => ctrans('validation.required', ['attribute' => 'email']), ]; } protected function prepareForValidation() { $input = $this->all(); $input = $this->decodePrimaryKeys($input); $this->replace($input); } }