I am trying to validate input quantity of an item in Laravel. How will I do this using request()->validate([])
? I want to validate if the input
quantity from user is greater
than the quantity of item from database
.
Also, is it possible to return an error
message if the entered quantity
is greater than
the quantity from database?
Here's my validation, I know this is wrong.
public function deduct(Request $request)
{
$item = Inventory::findOrFail($request->itemid);
request()->validate([
'quantity' => $item->quantity > $request->quantity
]);
}