Files
ladill-woo-manager/app/Http/Controllers/Woo/IntegrationController.php
T
isaaccladandCursor 1b0831b176 Extend integrations hub with more channels, caching, and refresh.
Cache per-store status for five minutes, add TikTok/Reddit/Meta cards, and let merchants refresh without reloading WordPress on every visit.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-08 07:37:41 +00:00

42 lines
1.2 KiB
PHP

<?php
namespace App\Http\Controllers\Woo;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Woo\Concerns\ResolvesWooContext;
use App\Services\Woo\IntegrationStatusService;
use Illuminate\Http\Request;
use Illuminate\View\View;
class IntegrationController extends Controller
{
use ResolvesWooContext;
public function __construct(private IntegrationStatusService $integrations) {}
public function index(Request $request): View
{
$store = $this->currentStore($request);
$payload = $this->integrations->forStore($store);
return view('woo.integrations.index', [
'store' => $store,
'reachable' => $payload['reachable'],
'cached' => (bool) ($payload['cached'] ?? false),
'integrations' => $payload['integrations'],
]);
}
public function refresh(Request $request): \Illuminate\Http\RedirectResponse
{
$store = $this->currentStore($request);
if ($store) {
$this->integrations->forStore($store, refresh: true);
}
return redirect()
->route('woo.integrations.index')
->with('status', 'Integration status refreshed.');
}
}