Skip to content

Commit

Permalink
feat(shops): add to stock modal too just in case
Browse files Browse the repository at this point in the history
  • Loading branch information
ScuffedNewt committed Aug 19, 2024
1 parent b043155 commit 1a83cdc
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions app/Http/Controllers/ShopController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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,
Expand Down

0 comments on commit 1a83cdc

Please sign in to comment.