user()->can('create', Product::class); } public function rules() { return [ 'product_key' => 'required|unique:products,product_key,null,null,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); } }