47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\AssessmentResource\Pages;
|
|
|
|
use App\Filament\Resources\AssessmentResource;
|
|
use App\Models\Assessment;
|
|
use Filament\Actions;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Resources\Pages\EditRecord;
|
|
|
|
class EditAssessment extends EditRecord
|
|
{
|
|
protected static string $resource = AssessmentResource::class;
|
|
|
|
protected function mutateFormDataBeforeSave(array $data): array
|
|
{
|
|
$exists = Assessment::where('teacher_subject_id', $data['teacher_subject_id'])
|
|
->where('student_id', $data['student_id'])
|
|
->where('id', '!=', $this->record->id) // ignore current record
|
|
->exists();
|
|
|
|
if ($exists) {
|
|
Notification::make()
|
|
->title('Failed to save')
|
|
->body('Data untuk kombinasi guru, mata pelajaran, dan siswa ini sudah ada.')
|
|
->danger()
|
|
->send();
|
|
|
|
$this->halt();
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
Actions\DeleteAction::make(),
|
|
];
|
|
}
|
|
|
|
public function getTitle(): string
|
|
{
|
|
return 'Edit Penilaian';
|
|
}
|
|
}
|