F
Filamentβ€’2y ago
Mehmet K.

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
toeknee
toekneeβ€’2y ago
Custom validation rule checking the stock count on select / input?
Mehmet K.
Mehmet K.OPβ€’2y ago
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
Tin
Tinβ€’2y ago
->rules([ function (Closure $get) { $myCustomValidation = false; return function (string $attribute, $value, Closure $fail) use($myCustomValidation) { if ($myCustomValidation === false) { $fail("Fail message"); } }; }, ]),
Tin
Tinβ€’2y ago
Tin
Tinβ€’2y ago
You can add this to an input and write your own validation return $fail if you want it to fail
Mehmet K.
Mehmet K.OPβ€’2y ago
Oh thank you I understand now
toeknee
toekneeβ€’2y ago
Exactly πŸ™‚
Want results from more Discord servers?
Add your server