- Implemented LecturerEdit and LecturerIndex components for managing lecturers. - Created StudentCreate and StudentEdit components for adding and editing students. - Developed StudentIndex component for listing students with search and pagination. - Added department and user types for better type safety. - Updated routes for lecturers and students, including reset password functionality. - Removed AppSidebar from dashboard for a cleaner layout.
54 lines
1.6 KiB
PHP
54 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin\Master;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\Admin\Master\DepartmentRequest;
|
|
use App\Http\Requests\PaginatedRequest;
|
|
use App\Models\Department;
|
|
use App\Services\Admin\Master\DepartmentService;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Inertia\Inertia;
|
|
use Inertia\Response;
|
|
|
|
class DepartmentController extends Controller
|
|
{
|
|
public function __construct(
|
|
private readonly DepartmentService $service
|
|
) {}
|
|
|
|
public function index(PaginatedRequest $request): Response
|
|
{
|
|
return Inertia::render('admin/master/departments/index', [
|
|
'departments' => $this->service->paginated(...$request->validatedWithDefaults()),
|
|
]);
|
|
}
|
|
|
|
public function store(DepartmentRequest $request): RedirectResponse
|
|
{
|
|
$this->service->create($request->validated());
|
|
|
|
Inertia::flash('toast', ['type' => 'success', 'message' => 'Jurusan berhasil ditambahkan.']);
|
|
|
|
return to_route('admin.master.departments.index');
|
|
}
|
|
|
|
public function update(DepartmentRequest $request, Department $department): RedirectResponse
|
|
{
|
|
$this->service->update($department, $request->validated());
|
|
|
|
Inertia::flash('toast', ['type' => 'success', 'message' => 'Jurusan berhasil diperbarui.']);
|
|
|
|
return to_route('admin.master.departments.index');
|
|
}
|
|
|
|
public function destroy(Department $department): RedirectResponse
|
|
{
|
|
$this->service->delete($department);
|
|
|
|
Inertia::flash('toast', ['type' => 'success', 'message' => 'Jurusan berhasil dihapus.']);
|
|
|
|
return back();
|
|
}
|
|
}
|