| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- namespace App\Controllers\Api;
- use CodeIgniter\HTTP\ResponseInterface;
- class BrochureController extends BaseApiController
- {
- /**
- * Get brochure request list
- */
- public function index()
- {
- $auth = $this->requireAuth();
- if ($auth instanceof ResponseInterface) {
- return $auth;
- }
- $params = $this->getPaginationParams();
- $builder = $this->getDB()->table('brochure_requests');
- // Search by applicant name
- $name = $this->request->getGet('name');
- if ($name) {
- $builder->like('applicant_name', $name);
- }
- $builder->orderBy('id', 'DESC');
- $result = $this->paginatedResponse($builder, $params);
- return $this->respondSuccess($result);
- }
- /**
- * Update brochure request status
- */
- public function updateStatus($id)
- {
- $auth = $this->requireAuth();
- if ($auth instanceof ResponseInterface) {
- return $auth;
- }
- $json = $this->request->getJSON();
- $data = [
- 'status' => $json->status ?? '접수',
- 'updated_at' => date('Y-m-d H:i:s')
- ];
- $builder = $this->getDB()->table('brochure_requests');
- $builder->where('id', $id)->update($data);
- return $this->respondSuccess(null, '상태가 변경되었습니다.');
- }
- /**
- * Delete brochure request
- */
- public function delete($id = null)
- {
- $auth = $this->requireAuth();
- if ($auth instanceof ResponseInterface) {
- return $auth;
- }
- $builder = $this->getDB()->table('brochure_requests');
- $builder->where('id', $id)->delete();
- return $this->respondSuccess(null, '브로셔 요청이 삭제되었습니다.');
- }
- /**
- * Export to Excel
- */
- public function exportExcel()
- {
- $auth = $this->requireAuth();
- if ($auth instanceof ResponseInterface) {
- return $auth;
- }
- // TODO: Implement Excel export logic
- return $this->respondSuccess(null, 'Excel export endpoint');
- }
- }
|