where('id', $value)->select(['id', 'stock', 'security_stock'])->first(); if (is_null($product)) { $fail(__('product_id is invalid')); return; } // Get the sellable stock $sellable_stock = ($product->security_stock) ? $product->stock - $product->security_stock : $product->stock; if ($this->product_quantity > $sellable_stock) { $fail(sprintf(':attribute (%s) too much requested, product stock is: %s', $this->product_quantity, $product->stock)); } } }