user()->can('create', Invoice::class) || auth()->user()->can('create', Quote::class) || auth()->user()->can('create', RecurringInvoice::class) || auth()->user()->can('create', Credit::class) || auth()->user()->can('create', PurchaseOrder::class); } public function rules() { $rules = [ 'entity' => 'bail|sometimes|string', 'entity_id' => 'bail|sometimes|string', 'settings_type' => 'bail|required|in:company,group,client', 'settings' => 'sometimes', 'group_id' => 'sometimes', 'client_id' => 'sometimes', ]; return $rules; } public function prepareForValidation() { $input = $this->all(); $input = $this->decodePrimaryKeys($input); $input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : []; $input['amount'] = 0; $input['balance'] = 0; $input['number'] = ctrans('texts.live_preview').' #'.rand(0, 1000); $this->replace($input); } }