Initial project import for team collaboration.
Exclude local docs, MCP, and secrets via gitignore. Made-with: Cursor
This commit is contained in:
58
app/Controllers/Admin/SelectLocalGovernment.php
Normal file
58
app/Controllers/Admin/SelectLocalGovernment.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\LocalGovernmentModel;
|
||||
use Config\Roles;
|
||||
|
||||
class SelectLocalGovernment extends BaseController
|
||||
{
|
||||
/**
|
||||
* 지자체 선택 화면 (super admin 전용)
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
if ((int) session()->get('mb_level') !== Roles::LEVEL_SUPER_ADMIN) {
|
||||
return redirect()->to(site_url('admin'))->with('error', '지자체 선택은 super admin만 사용할 수 있습니다.');
|
||||
}
|
||||
|
||||
$list = model(LocalGovernmentModel::class)
|
||||
->where('lg_state', 1)
|
||||
->orderBy('lg_name', 'ASC')
|
||||
->findAll();
|
||||
|
||||
return view('admin/layout', [
|
||||
'title' => '지자체 선택',
|
||||
'content' => view('admin/select_local_government/index', [
|
||||
'list' => $list,
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 선택 처리: admin_selected_lg_idx 저장 후 관리자 대시보드로 이동
|
||||
*/
|
||||
public function store()
|
||||
{
|
||||
if ((int) session()->get('mb_level') !== Roles::LEVEL_SUPER_ADMIN) {
|
||||
return redirect()->to(site_url('admin'))->with('error', '지자체 선택은 super admin만 사용할 수 있습니다.');
|
||||
}
|
||||
|
||||
$lgIdx = (int) $this->request->getPost('lg_idx');
|
||||
if ($lgIdx <= 0) {
|
||||
return redirect()->back()
|
||||
->with('error', '지자체를 선택해 주세요.');
|
||||
}
|
||||
|
||||
$exists = model(LocalGovernmentModel::class)->find($lgIdx);
|
||||
if ($exists === null) {
|
||||
return redirect()->back()
|
||||
->with('error', '선택한 지자체를 찾을 수 없습니다.');
|
||||
}
|
||||
|
||||
session()->set('admin_selected_lg_idx', $lgIdx);
|
||||
|
||||
return redirect()->to(site_url('admin'))->with('success', $exists->lg_name . ' 지자체로 전환되었습니다.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user