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