accountUser($request); $storeScope = $this->storeScope($request); $stores = WooStore::query() ->where('user_id', $user->id) ->when($storeScope !== null, fn ($q) => $q->whereIn('id', $storeScope)) ->latest('updated_at') ->get(); return view('woo.stores.index', [ 'stores' => $stores, 'currentStore' => $this->currentStore->resolve($user, $storeScope), 'hasPaidPlan' => $this->subscriptions->hasPaidPlan($user), 'storeCount' => $this->subscriptions->connectedStoreCount($user), 'storeLimit' => $this->subscriptions->maxStores($user), 'canConnectMore' => $this->isStoreOwner($request) && $this->subscriptions->canConnectStore($user), 'isStoreOwner' => $this->isStoreOwner($request), ]); } public function destroy(Request $request, WooStore $store): RedirectResponse { abort_if(! $this->isStoreOwner($request), 403); abort_if($store->user_id !== $this->accountUser($request)->id, 403); $store->update(['status' => WooStore::STATUS_DISCONNECTED]); if ((int) session(CurrentWooStore::SESSION_KEY) === $store->id) { session()->forget(CurrentWooStore::SESSION_KEY); } return back()->with('success', 'Store disconnected. Install the Ladill plugin again to reconnect.'); } }