How can I do stock control?
I have 3 different tables as orders order order_products and order_exits I need to get the stocks of the products I want to output from order_products with their names and stocks. But these products have a stock, when I select 2 products, I need to give a warning if I want to output more products than in stock. If the stock numbers are correct, I need to deduct them from the stock. Since the create process is directly created in Filament, I don't know what kind of code I should write.
7 Replies
Custom validation rule checking the stock count on select / input?
I wonder exactly how I can do it, I am quite new to filament, I don't know how to recognise customised rules. You have a chance to give an example
->rules([
function (Closure $get) {
$myCustomValidation = false;
return function (string $attribute, $value, Closure $fail) use($myCustomValidation) {
if ($myCustomValidation === false) {
$fail("Fail message");
}
};
},
]),
You can add this to an input
and write your own validation
return $fail if you want it to fail
Oh thank you I understand now
Exactly π