39 lines
929 B
PHP
39 lines
929 B
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;
|
|
}
|
|
}
|