feat: improve admin master data management
This commit is contained in:
@@ -18,25 +18,19 @@ class Company extends BaseController
|
||||
{
|
||||
helper('admin');
|
||||
$lgIdx = admin_effective_lg_idx();
|
||||
if (!$lgIdx) {
|
||||
return redirect()->to(site_url('admin'))->with('error', '지자체를 선택해 주세요.');
|
||||
if (! $lgIdx) {
|
||||
return redirect()->to(work_area_home_url())->with('error', '지자체를 선택해 주세요.');
|
||||
}
|
||||
|
||||
$list = $this->model->where('cp_lg_idx', $lgIdx)->orderBy('cp_idx', 'DESC')->paginate(20);
|
||||
$list = $this->model->where('cp_lg_idx', $lgIdx)->orderBy('cp_idx', 'DESC')->paginate(20);
|
||||
$pager = $this->model->pager;
|
||||
|
||||
return view('admin/layout', [
|
||||
'title' => '업체 관리',
|
||||
'content' => view('admin/company/index', ['list' => $list, 'pager' => $pager]),
|
||||
]);
|
||||
return $this->renderWorkPage('업체 관리', 'admin/company/index', ['list' => $list, 'pager' => $pager]);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('admin/layout', [
|
||||
'title' => '업체 등록',
|
||||
'content' => view('admin/company/create'),
|
||||
]);
|
||||
return $this->renderWorkPage('업체 등록', 'admin/company/create');
|
||||
}
|
||||
|
||||
public function store()
|
||||
@@ -66,29 +60,26 @@ class Company extends BaseController
|
||||
'cp_regdate' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
return redirect()->to(site_url('admin/companies'))->with('success', '업체가 등록되었습니다.');
|
||||
return redirect()->to(mgmt_url('companies'))->with('success', '업체가 등록되었습니다.');
|
||||
}
|
||||
|
||||
public function edit(int $id)
|
||||
{
|
||||
helper('admin');
|
||||
$item = $this->model->find($id);
|
||||
if (!$item || (int) $item->cp_lg_idx !== admin_effective_lg_idx()) {
|
||||
return redirect()->to(site_url('admin/companies'))->with('error', '업체를 찾을 수 없습니다.');
|
||||
if (! $item || (int) $item->cp_lg_idx !== admin_effective_lg_idx()) {
|
||||
return redirect()->to(mgmt_url('companies'))->with('error', '업체를 찾을 수 없습니다.');
|
||||
}
|
||||
|
||||
return view('admin/layout', [
|
||||
'title' => '업체 수정',
|
||||
'content' => view('admin/company/edit', ['item' => $item]),
|
||||
]);
|
||||
return $this->renderWorkPage('업체 수정', 'admin/company/edit', ['item' => $item]);
|
||||
}
|
||||
|
||||
public function update(int $id)
|
||||
{
|
||||
helper('admin');
|
||||
$item = $this->model->find($id);
|
||||
if (!$item || (int) $item->cp_lg_idx !== admin_effective_lg_idx()) {
|
||||
return redirect()->to(site_url('admin/companies'))->with('error', '업체를 찾을 수 없습니다.');
|
||||
if (! $item || (int) $item->cp_lg_idx !== admin_effective_lg_idx()) {
|
||||
return redirect()->to(mgmt_url('companies'))->with('error', '업체를 찾을 수 없습니다.');
|
||||
}
|
||||
|
||||
$rules = [
|
||||
@@ -110,18 +101,19 @@ class Company extends BaseController
|
||||
'cp_state' => (int) $this->request->getPost('cp_state'),
|
||||
]);
|
||||
|
||||
return redirect()->to(site_url('admin/companies'))->with('success', '업체가 수정되었습니다.');
|
||||
return redirect()->to(mgmt_url('companies'))->with('success', '업체가 수정되었습니다.');
|
||||
}
|
||||
|
||||
public function delete(int $id)
|
||||
{
|
||||
helper('admin');
|
||||
$item = $this->model->find($id);
|
||||
if (!$item || (int) $item->cp_lg_idx !== admin_effective_lg_idx()) {
|
||||
return redirect()->to(site_url('admin/companies'))->with('error', '업체를 찾을 수 없습니다.');
|
||||
if (! $item || (int) $item->cp_lg_idx !== admin_effective_lg_idx()) {
|
||||
return redirect()->to(mgmt_url('companies'))->with('error', '업체를 찾을 수 없습니다.');
|
||||
}
|
||||
|
||||
$this->model->delete($id);
|
||||
return redirect()->to(site_url('admin/companies'))->with('success', '업체가 삭제되었습니다.');
|
||||
|
||||
return redirect()->to(mgmt_url('companies'))->with('success', '업체가 삭제되었습니다.');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user