- 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.
52 lines
1.8 KiB
PHP
52 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin\Manage;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\Admin\Manage\SubmissionRequest;
|
|
use App\Models\Assignment;
|
|
use App\Models\Submission;
|
|
use App\Services\Admin\Manage\SubmissionService;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Inertia\Inertia;
|
|
use Inertia\Response;
|
|
|
|
class SubmissionController extends Controller
|
|
{
|
|
public function __construct(
|
|
private readonly SubmissionService $service,
|
|
) {}
|
|
|
|
public function index(Assignment $assignment): Response
|
|
{
|
|
$assignment->load(['courseClass.course', 'courseClass.lecturer.user.profile', 'courseClass.academicTerm']);
|
|
|
|
return Inertia::render('admin/manage/assignments/submissions', [
|
|
'assignment' => $assignment,
|
|
'submissions' => $this->service->forAssignment($assignment),
|
|
'availableStudents' => $this->service->availableStudents($assignment),
|
|
]);
|
|
}
|
|
|
|
public function store(SubmissionRequest $request, Assignment $assignment): RedirectResponse
|
|
{
|
|
$this->service->create($assignment, $request->validated(), $request->file('file'));
|
|
|
|
return Inertia::flash('toast', ['type' => 'success', 'message' => 'Pengumpulan berhasil ditambahkan.'])->back();
|
|
}
|
|
|
|
public function update(SubmissionRequest $request, Assignment $assignment, Submission $submission): RedirectResponse
|
|
{
|
|
$this->service->update($submission, $request->validated(), $request->file('file'));
|
|
|
|
return Inertia::flash('toast', ['type' => 'success', 'message' => 'Pengumpulan berhasil diperbarui.'])->back();
|
|
}
|
|
|
|
public function destroy(Assignment $assignment, Submission $submission): RedirectResponse
|
|
{
|
|
$this->service->delete($submission);
|
|
|
|
return Inertia::flash('toast', ['type' => 'success', 'message' => 'Pengumpulan berhasil dihapus.'])->back();
|
|
}
|
|
}
|