first commit
This commit is contained in:
71
app/Http/Controllers/CorrectionRequestController.php
Normal file
71
app/Http/Controllers/CorrectionRequestController.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Submission;
|
||||
use App\Models\SubmissionCorrectionRequest;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CorrectionRequestController extends Controller
|
||||
{
|
||||
/** Pegawai cipta permohonan pembetulan (wajib: no muka surat, lokasi, penerangan). */
|
||||
public function store(Request $request, Submission $submission)
|
||||
{
|
||||
$this->authorize('review', $submission);
|
||||
|
||||
$data = $request->validate([
|
||||
'checklist_item_id' => ['nullable', 'exists:checklist_items,id'],
|
||||
'page_reference' => ['required', 'string', 'max:50'],
|
||||
'location' => ['required', 'string', 'max:255'],
|
||||
'description' => ['required', 'string', 'max:2000'],
|
||||
], [], [
|
||||
'page_reference' => 'no muka surat',
|
||||
'location' => 'lokasi/seksyen/item',
|
||||
'description' => 'penerangan pembetulan',
|
||||
]);
|
||||
|
||||
$submission->correctionRequests()->create(array_merge($data, [
|
||||
'status' => 'terbuka',
|
||||
'created_by' => auth()->id(),
|
||||
]));
|
||||
|
||||
activity('serahan')->performedOn($submission)->causedBy(auth()->user())
|
||||
->log('Permohonan pembetulan dibuat');
|
||||
|
||||
return back()->with('success', 'Permohonan pembetulan ditambah.');
|
||||
}
|
||||
|
||||
/** Perunding jawab permohonan pembetulan. */
|
||||
public function respond(Request $request, SubmissionCorrectionRequest $correction)
|
||||
{
|
||||
$submission = $correction->submission;
|
||||
$this->authorize('respondCorrection', $submission);
|
||||
|
||||
$data = $request->validate([
|
||||
'consultant_response' => ['required', 'string', 'max:2000'],
|
||||
], [], ['consultant_response' => 'maklum balas']);
|
||||
|
||||
$correction->update([
|
||||
'consultant_response' => $data['consultant_response'],
|
||||
'status' => 'dijawab',
|
||||
'responded_at' => now(),
|
||||
'responded_by' => auth()->id(),
|
||||
]);
|
||||
|
||||
return back()->with('success', 'Maklum balas pembetulan dihantar.');
|
||||
}
|
||||
|
||||
/** Pegawai tutup permohonan pembetulan. */
|
||||
public function resolve(SubmissionCorrectionRequest $correction)
|
||||
{
|
||||
$this->authorize('review', $correction->submission);
|
||||
|
||||
$correction->update([
|
||||
'status' => 'selesai',
|
||||
'resolved_at' => now(),
|
||||
'resolved_by' => auth()->id(),
|
||||
]);
|
||||
|
||||
return back()->with('success', 'Permohonan pembetulan ditandakan selesai.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user