File manager - Edit - /home/webapp69.cm.in.th/u69319090039/Shop39/app/Controllers/SellerRequestController.php
Back
<?php class SellerRequestController extends Controller { public function showApply(): void { $user = Auth::user(); $sellerModel = new SellerProfile(); $existingProfile = $sellerModel->findByUserId($user['id']); $this->render('seller/apply', [ 'title' => 'สมัครเปิดร้านค้า', 'user' => $user, 'seller' => $existingProfile ]); } public function submitApply(): void { $this->validateCsrf(); $user = Auth::user(); $shopName = Security::sanitizeString($_POST['shop_name'] ?? ''); $description = Security::sanitizeString($_POST['description'] ?? ''); $phone = Security::sanitizeString($_POST['phone'] ?? ''); $address = Security::sanitizeString($_POST['address'] ?? ''); $promptpay = Security::sanitizeString($_POST['promptpay_number'] ?? ''); $bankAccount = Security::sanitizeString($_POST['bank_account'] ?? ''); $latitude = isset($_POST['latitude']) && $_POST['latitude'] !== '' ? (float)$_POST['latitude'] : null; $longitude = isset($_POST['longitude']) && $_POST['longitude'] !== '' ? (float)$_POST['longitude'] : null; if (empty($shopName) || empty($phone) || empty($address)) { Session::setFlash('danger', 'กรุณากรอกข้อมูลร้านค้าให้ครบถ้วน'); $this->redirect('seller/apply'); } $sellerModel = new SellerProfile(); $existing = $sellerModel->findByUserId($user['id']); // Security check: Block application if store is suspended or banned if ($existing && empty($existing['deleted_at'])) { if ($existing['status'] === 'suspended') { Session::setFlash('warning', 'ร้านค้าของคุณถูกระงับการใช้งานชั่วคราว ไม่สามารถส่งคำขอใหม่ได้ กรุณาติดต่อผู้ดูแลระบบ'); $this->redirect('seller/apply'); } if ($existing['status'] === 'banned') { Session::setFlash('danger', 'ร้านค้าของคุณถูกแบน ไม่สามารถส่งคำขอใหม่ได้'); $this->redirect('seller/apply'); } if ($existing['status'] === 'approved') { Session::setFlash('success', 'ร้านค้าของคุณได้รับการอนุมัติแล้ว'); $this->redirect('seller/dashboard'); } if ($existing['status'] === 'pending') { Session::setFlash('info', 'คำขอของคุณอยู่ระหว่างการตรวจสอบ'); $this->redirect('seller/apply'); } } $slug = Security::slugify($shopName); if ($existing) { // Re-submit application (for rejected or previously soft-deleted) $sellerModel->update($existing['id'], [ 'shop_name' => $shopName, 'slug' => $slug, 'description' => $description, 'phone' => $phone, 'address' => $address, 'latitude' => $latitude, 'longitude' => $longitude, 'promptpay_number' => $promptpay, 'bank_account' => $bankAccount, 'status' => 'pending', 'rejection_reason' => null, 'deleted_at' => null ]); } else { // New application $sellerModel->create([ 'user_id' => $user['id'], 'shop_name' => $shopName, 'slug' => $slug, 'description' => $description, 'phone' => $phone, 'address' => $address, 'latitude' => $latitude, 'longitude' => $longitude, 'promptpay_number' => $promptpay, 'bank_account' => $bankAccount, 'id_card_doc' => 'id_doc_sample.pdf', 'status' => 'pending' ]); } Session::setFlash('success', 'ส่งคำขอสมัครเปิดร้านค้าเรียบร้อยแล้ว กรุณารอผู้ดูแลระบบตรวจสอบอนุมัติ'); $this->redirect('seller/apply'); } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.23 |
proxy
|
phpinfo
|
Settings