|
- <?php
-
- namespace App\Http\Controllers\Items;
-
- use App\Models\Item;
- use App\Models\Stock;
- use Framework\Routing\Router;
-
- class ShowWithdrawStockFormController
- {
- public function handle(Router $router)
- {
- if (!session()->has('user_id')) {
- return redirect($router->route('show-register-form'));
- }
-
- $parameters = $router->current()->parameters();
-
- $item = Item::find((int) $parameters['item']);
-
- if (!$item) {
- return redirect($router->route('show-items'));
- }
-
- $stock = Stock::where('item_id', $item->id)->all();
- $stock = array_filter($stock, fn($row) => $row->quantity > 0);
-
- return view('items/withdraw', [
- 'item' => $item,
- 'stock' => $stock,
- 'withdrawAction' => $router->route('withdraw-stock', ['item' => $item->id]),
- 'csrf' => csrf(),
- ]);
- }
- }
|