Add Woo Manager Pro with multi-store switching and free-tier limits.
Deploy Ladill Woo Manager / deploy (push) Successful in 51s
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>
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Woo\Concerns;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\WooStore;
|
||||
use App\Support\CurrentWooStore;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
trait ResolvesWooContext
|
||||
{
|
||||
protected function accountUser(Request $request): User
|
||||
{
|
||||
return ladill_account() ?? $request->user();
|
||||
}
|
||||
|
||||
protected function currentStore(Request $request): ?WooStore
|
||||
{
|
||||
return app(CurrentWooStore::class)->resolve($this->accountUser($request));
|
||||
}
|
||||
|
||||
protected function currentStoreOrFail(Request $request): WooStore
|
||||
{
|
||||
$store = $this->currentStore($request);
|
||||
abort_if(! $store, 404, 'Connect a WooCommerce store to continue.');
|
||||
|
||||
return $store;
|
||||
}
|
||||
|
||||
protected function authorizedStore(Request $request, int $storeId): WooStore
|
||||
{
|
||||
return WooStore::query()
|
||||
->where('user_id', $this->accountUser($request)->id)
|
||||
->whereKey($storeId)
|
||||
->where('status', WooStore::STATUS_ACTIVE)
|
||||
->firstOrFail();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user