49 lines
1.1 KiB
PHP
49 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Services\DepartmentService;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\View\View;
|
|
|
|
class DepartmentController extends Controller
|
|
{
|
|
public function __construct(
|
|
private readonly DepartmentService $departmentService
|
|
) {}
|
|
|
|
/**
|
|
* 부서 목록 (Blade 화면만)
|
|
*/
|
|
public function index(Request $request): View
|
|
{
|
|
return view('departments.index');
|
|
}
|
|
|
|
/**
|
|
* 부서 생성 화면
|
|
*/
|
|
public function create(): View
|
|
{
|
|
$departments = $this->departmentService->getActiveDepartments();
|
|
|
|
return view('departments.create', compact('departments'));
|
|
}
|
|
|
|
/**
|
|
* 부서 수정 화면
|
|
*/
|
|
public function edit(int $id): View
|
|
{
|
|
$department = $this->departmentService->getDepartmentById($id);
|
|
|
|
if (! $department) {
|
|
abort(404, '부서를 찾을 수 없습니다.');
|
|
}
|
|
|
|
$departments = $this->departmentService->getActiveDepartments();
|
|
|
|
return view('departments.edit', compact('department', 'departments'));
|
|
}
|
|
}
|