Deploy Ladill Woo Manager / deploy (push) Successful in 55s
Sync catalog via plugin webhooks and REST proxy, with list/create/edit UI and updated logo from monolith assets. Co-authored-by: Cursor <cursoragent@cursor.com>
41 lines
1.4 KiB
PHP
41 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Woo;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\WooOrder;
|
|
use App\Models\WooProduct;
|
|
use App\Models\WooCategory;
|
|
use App\Models\WooStore;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\View\View;
|
|
|
|
class DashboardController extends Controller
|
|
{
|
|
public function index(Request $request): View
|
|
{
|
|
$user = $request->user();
|
|
$storeIds = WooStore::query()->where('user_id', $user->id)->pluck('id');
|
|
|
|
$stats = [
|
|
'stores' => WooStore::query()->where('user_id', $user->id)->where('status', WooStore::STATUS_ACTIVE)->count(),
|
|
'orders_new' => WooOrder::query()->whereIn('woo_store_id', $storeIds)->where('fulfillment_status', WooOrder::FULFILLMENT_NEW)->count(),
|
|
'orders_open' => WooOrder::query()->whereIn('woo_store_id', $storeIds)->whereNotIn('fulfillment_status', [
|
|
WooOrder::FULFILLMENT_DELIVERED,
|
|
WooOrder::FULFILLMENT_CANCELLED,
|
|
])->count(),
|
|
'products' => WooProduct::query()->whereIn('woo_store_id', $storeIds)->count(),
|
|
'categories' => WooCategory::query()->whereIn('woo_store_id', $storeIds)->count(),
|
|
];
|
|
|
|
$recent = WooOrder::query()
|
|
->whereIn('woo_store_id', $storeIds)
|
|
->with('store')
|
|
->latest('created_at')
|
|
->limit(8)
|
|
->get();
|
|
|
|
return view('woo.dashboard', compact('stats', 'recent'));
|
|
}
|
|
}
|