48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\AcademicYearResource\Pages;
|
|
|
|
use App\Filament\Resources\AcademicYearResource;
|
|
use App\Models\AcademicYear;
|
|
use App\Models\ClassStudent;
|
|
use Filament\Actions;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Resources\Pages\EditRecord;
|
|
|
|
class EditAcademicYear extends EditRecord
|
|
{
|
|
protected static string $resource = AcademicYearResource::class;
|
|
|
|
public function getTitle(): string
|
|
{
|
|
return 'Edit Tahun Ajaran';
|
|
}
|
|
|
|
protected function mutateFormDataBeforeSave(array $data): array
|
|
{
|
|
$exists = AcademicYear::where('name', $data['name'])
|
|
->exists();
|
|
|
|
if ($exists) {
|
|
Notification::make()
|
|
->title('Failed to save')
|
|
->body('Data sudah ada')
|
|
->danger()
|
|
->send();
|
|
|
|
$this->halt(); // Stop the save process
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
Actions\DeleteAction::make(),
|
|
Actions\ForceDeleteAction::make(),
|
|
Actions\RestoreAction::make(),
|
|
];
|
|
}
|
|
}
|