From f237b091e15704e7aa99b9259f53e0838594f491 Mon Sep 17 00:00:00 2001 From: Jing Li Date: Fri, 31 May 2024 10:47:40 +0800 Subject: [PATCH] Fix --- app/Http/Controllers/Api/LedgerController.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Api/LedgerController.php b/app/Http/Controllers/Api/LedgerController.php index e3e4268..33d0969 100644 --- a/app/Http/Controllers/Api/LedgerController.php +++ b/app/Http/Controllers/Api/LedgerController.php @@ -6,6 +6,7 @@ use App\Exceptions\RuntimeException; use App\Models\Keyword; use App\Models\Ledger; use App\Models\LedgerItem; +use App\Models\Store; use App\Models\TaskLedger; use App\Models\TaskPerformance; use Illuminate\Http\Request; @@ -199,15 +200,19 @@ class LedgerController extends Controller $storeId = $request->whenFilled('store_id', fn ($storeId) => $storeId, fn () => $user->store_id); + if (is_null($store = Store::find($storeId))) { + throw new RuntimeException('门店未找到'); + } + /** @var \App\Models\Ledger|null */ $ledger = Ledger::with(['items']) - ->where('store_id', $storeId) + ->where('store_id', $store->id) ->where('date', $date) ->first(); $items = []; - if ($user->store?->isLotteryStore()) { + if ($store->isLotteryStore()) { /** @var \Illuminate\Database\Eloquent\Collection */ $lotteryTypes = Keyword::filter(['parent_key' => 'lottery_type']) ->oldest('sort')