File manager - Edit - /home/webapp69.cm.in.th/u69319090028/Shop/app/Controllers/SellerController.php
Back
<?php /** * SellerController * Handles Seller Dashboard overview, Store Onboarding, and Store Branding */ require_once __DIR__ . '/../Core/Controller.php'; require_once __DIR__ . '/../Services/StoreService.php'; require_once __DIR__ . '/../Helpers/Auth.php'; require_once __DIR__ . '/../Helpers/Session.php'; require_once __DIR__ . '/../Helpers/Url.php'; class SellerController extends Controller { private StoreService $storeService; public function __construct() { $this->storeService = new StoreService(); } public function dashboard(): void { $userId = Auth::id(); $store = $this->storeService->getStoreByUserId($userId); if (!$store) { $this->redirect('/seller/register'); } $stats = $this->storeService->getStoreStats($userId); $this->render('seller/dashboard', [ 'store' => $store, 'stats' => $stats, 'pageTitle' => 'Seller Center - ' . e($store['store_name']) . ' - CARGOO', 'activeNav' => 'dashboard' ], 'seller'); } public function showRegister(): void { $userId = Auth::id(); $store = $this->storeService->getStoreByUserId($userId); if ($store) { $this->redirect('/seller'); } $this->render('seller/register', [ 'pageTitle' => 'เปิดร้านค้าออนไลน์กับ CARGOO - Seller Center' ], 'main'); } public function register(): void { $userId = Auth::id(); $logoFile = $_FILES['logo'] ?? null; $coverFile = $_FILES['cover_image'] ?? null; $result = $this->storeService->registerStore($userId, $_POST, $logoFile, $coverFile); if (!$result['success']) { Session::setFlash('danger', $result['message']); $this->redirect('/seller/register'); } Session::setFlash('success', $result['message']); $this->redirect('/seller'); } public function showStore(): void { $userId = Auth::id(); $store = $this->storeService->getStoreByUserId($userId); if (!$store) { $this->redirect('/seller/register'); } $this->render('seller/store', [ 'store' => $store, 'pageTitle' => 'ตั้งค่าร้านค้าและภาพลักษณ์ (Store Branding) - CARGOO', 'activeNav' => 'store' ], 'seller'); } public function updateStore(): void { $userId = Auth::id(); $logoFile = $_FILES['logo'] ?? null; $coverFile = $_FILES['cover_image'] ?? null; $result = $this->storeService->updateStoreBranding($userId, $_POST, $logoFile, $coverFile); if (!$result['success']) { Session::setFlash('danger', $result['message']); } else { Session::setFlash('success', $result['message']); } $this->redirect('/seller/store'); } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.23 |
proxy
|
phpinfo
|
Settings