user()->can('create', Product::class); } public function rules() { return [ //'product_key' => 'unique:products,product_key,'.$this->product->id.',id,company_id,'.auth()->user()->companyId(), 'cost' => 'numeric', 'price' => 'numeric', 'quantity' => 'numeric', ]; } protected function prepareForValidation() { $input = $this->all(); if (!isset($input['quantity']) || $input['quantity'] < 1) { $input['quantity'] = 1; } $this->replace($input); } }