siakad-itm/app/Http/Controllers/Admin/Manage/AssignmentController.php
Yoga Pangestu b0e16a6cd5 feat: add assignment and submission management features
- Created SubmissionService to handle submission logic for assignments.
- Added migrations for assignments and submissions tables.
- Implemented AssignmentSeeder and SubmissionSeeder for initial data.
- Updated DatabaseSeeder to include new seeders.
- Enhanced app sidebar to include assignments navigation.
- Developed datetime field component for better date and time input.
- Created assignment management pages with data tables for assignments and submissions.
- Implemented forms for creating and editing assignments and submissions.
- Added routes for assignment and submission management in admin panel.
- Defined types for assignments and submissions to improve type safety.
2026-08-24 18:15:44 +07:00

55 lines
1.8 KiB
PHP

<?php
namespace App\Http\Controllers\Admin\Manage;
use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\Manage\AssignmentRequest;
use App\Http\Requests\PaginatedRequest;
use App\Models\Assignment;
use App\Services\Admin\Manage\AssignmentService;
use App\Services\Admin\Manage\CourseClassService;
use Illuminate\Http\RedirectResponse;
use Inertia\Inertia;
use Inertia\Response;
class AssignmentController extends Controller
{
public function __construct(
private readonly AssignmentService $service,
private readonly CourseClassService $courseClassService,
) {}
public function index(PaginatedRequest $request): Response
{
return Inertia::render('admin/manage/assignments/index', [
'assignments' => $this->service->paginated(...$request->validatedWithDefaults()),
'courseClasses' => $this->courseClassService->getAllForSelect(),
]);
}
public function store(AssignmentRequest $request): RedirectResponse
{
$this->service->create($request->validated(), $request->file('attachment'));
Inertia::flash('toast', ['type' => 'success', 'message' => 'Tugas berhasil ditambahkan.']);
return to_route('admin.manage.assignments.index');
}
public function update(AssignmentRequest $request, Assignment $assignment): RedirectResponse
{
$this->service->update($assignment, $request->validated(), $request->file('attachment'));
Inertia::flash('toast', ['type' => 'success', 'message' => 'Tugas berhasil diperbarui.']);
return to_route('admin.manage.assignments.index');
}
public function destroy(Assignment $assignment): RedirectResponse
{
$this->service->delete($assignment);
return Inertia::flash('toast', ['type' => 'success', 'message' => 'Tugas berhasil dihapus.'])->back();
}
}