49 lines
1.3 KiB
PHP

<?php
namespace App\Filament\Resources\HomeRoomTeacherResource\Pages;
use App\Filament\Resources\HomeRoomTeacherResource;
use App\Models\ClassStudent;
use App\Models\HomeRoomTeacher;
use Filament\Actions;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\EditRecord;
class EditHomeRoomTeacher extends EditRecord
{
protected static string $resource = HomeRoomTeacherResource::class;
public function getTitle(): string
{
return 'Edit Guru Wali Kelas';
}
protected function mutateFormDataBeforeSave(array $data): array
{
$exists = HomeRoomTeacher::where('class_room_id', $data['class_room_id'])
->where('teacher_id', $data['teacher_id'])
->where('academic_year_id', $data['academic_year_id'])
->exists();
if ($exists) {
Notification::make()
->title('Failed to save')
->body('A record for this class room, teacher, and academic year combination already exists.')
->danger()
->send();
$this->halt(); // Stop the save process
}
return $data;
}
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
];
}
}