Deploy Ladill Woo Manager / deploy (push) Successful in 51s
Free: 1 store and 20 products. Pro/Business mirrors Invoice pricing (GHS 49/149) with wallet renewals, Paystack prepay, session-based store switcher, and scoped UI. Co-authored-by: Cursor <cursoragent@cursor.com>
54 lines
1.7 KiB
PHP
54 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Woo;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Controllers\Woo\Concerns\ResolvesWooContext;
|
|
use App\Models\WooStore;
|
|
use App\Services\Woo\SubscriptionService;
|
|
use App\Support\CurrentWooStore;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\View\View;
|
|
|
|
class StoreController extends Controller
|
|
{
|
|
use ResolvesWooContext;
|
|
|
|
public function __construct(
|
|
private SubscriptionService $subscriptions,
|
|
private CurrentWooStore $currentStore,
|
|
) {}
|
|
|
|
public function index(Request $request): View
|
|
{
|
|
$user = $this->accountUser($request);
|
|
$stores = WooStore::query()
|
|
->where('user_id', $user->id)
|
|
->latest('updated_at')
|
|
->get();
|
|
|
|
return view('woo.stores.index', [
|
|
'stores' => $stores,
|
|
'currentStore' => $this->currentStore->resolve($user),
|
|
'hasPaidPlan' => $this->subscriptions->hasPaidPlan($user),
|
|
'storeCount' => $this->subscriptions->connectedStoreCount($user),
|
|
'storeLimit' => $this->subscriptions->maxStores($user),
|
|
'canConnectMore' => $this->subscriptions->canConnectStore($user),
|
|
]);
|
|
}
|
|
|
|
public function destroy(Request $request, WooStore $store): RedirectResponse
|
|
{
|
|
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.');
|
|
}
|
|
}
|