From 1a83cdcb734d61732ad259aa1383d24704d73b4b Mon Sep 17 00:00:00 2001 From: ScuffedNewt Date: Tue, 20 Aug 2024 00:17:35 +0100 Subject: [PATCH] feat(shops): add to stock modal too just in case --- app/Http/Controllers/ShopController.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/ShopController.php b/app/Http/Controllers/ShopController.php index db89f2b32..7ce3958f2 100644 --- a/app/Http/Controllers/ShopController.php +++ b/app/Http/Controllers/ShopController.php @@ -85,6 +85,19 @@ public function getShop($id) { */ public function getShopStock(ShopManager $service, $id, $stockId) { $shop = Shop::where('id', $id)->where('is_active', 1)->first(); + if (!$shop) { + abort(404); + } + + if (count(getLimits($shop))) { + $service = new LimitManager; + if (!$service->checkLimits($shop)) { + flash($service->errors()->getMessages()['error'][0])->error(); + + return redirect()->to('shops'); + } + } + $stock = ShopStock::with('item')->where('id', $stockId)->where('shop_id', $id)->first(); $user = Auth::user(); @@ -98,10 +111,6 @@ public function getShopStock(ShopManager $service, $id, $stockId) { $userOwned = UserItem::where('user_id', $user->id)->where('item_id', $stock->item->id)->where('count', '>', 0)->get(); } - if (!$shop) { - abort(404); - } - return view('shops._stock_modal', [ 'shop' => $shop, 'stock' => $stock,