user()->can('edit', $this->purchase_order); } public function rules() { return [ 'action' => 'required', ]; } protected function prepareForValidation() { $input = $this->all(); if ($this->action) { $input['action'] = $this->action; } elseif (! array_key_exists('action', $input)) { $this->error_msg = 'Action is a required field'; } $this->replace($input); } public function messages() { return [ 'action' => $this->error_msg, ]; } }