user()->can('edit', $this->expense_category); } public function rules() { /* Ensure we have a client name, and that all emails are unique*/ $rules = []; if ($this->input('number')) { $rules['name'] = 'unique:expense_categories,name,'.$this->id.',id,company_id,'.$this->expense_category->name; } return $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(); $this->replace($input); } }