96 lines
3.2 KiB
PHP
96 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Pages;
|
|
|
|
use Filament\Forms\Components\Grid;
|
|
use Filament\Forms\Form;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Forms\Components\Textarea;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Pages\Page;
|
|
use Filament\Forms\Contracts\HasForms;
|
|
use Filament\Forms\Concerns\InteractsWithForms;
|
|
|
|
use App\Models\SchoolInformation as SchoolInformationModel;
|
|
|
|
class SchoolInformation extends Page implements HasForms
|
|
{
|
|
use InteractsWithForms;
|
|
|
|
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
|
protected static string $view = 'filament.pages.school-information';
|
|
protected static ?string $navigationGroup = 'Settings';
|
|
protected static ?int $navigationSort = 999; // Biar muncul paling bawah
|
|
|
|
public ?array $data = [];
|
|
|
|
public ?SchoolInformationModel $record = null;
|
|
|
|
public function mount(): void
|
|
{
|
|
$this->record = SchoolInformationModel::firstOrNew();
|
|
$this->form->fill($this->record->toArray());
|
|
}
|
|
|
|
public function form(Form $form): Form
|
|
{
|
|
return $form
|
|
->schema([
|
|
Grid::make(2)->schema([
|
|
TextInput::make('school_name')->label('Nama Sekolah')->required(),
|
|
TextInput::make('npsn')
|
|
->label('NPSN')
|
|
->numeric()
|
|
->nullable(),
|
|
TextInput::make('nss')
|
|
->label('NSS')
|
|
->nullable(),
|
|
Textarea::make('address')
|
|
->label('Alamat Sekolah')
|
|
->nullable(),
|
|
TextInput::make('postal_code')
|
|
->label('Kode Pos')
|
|
->numeric()
|
|
->nullable()
|
|
->default(null),
|
|
TextInput::make('sub_district')
|
|
->label('Desa / Kelurahan')
|
|
->nullable(),
|
|
TextInput::make('district')
|
|
->label('Kecamatan')
|
|
->nullable(),
|
|
TextInput::make('city')
|
|
->label('Kota / Kabupaten')
|
|
->nullable(),
|
|
TextInput::make('province')
|
|
->label('Provinsi')
|
|
->nullable(),
|
|
TextInput::make('email')
|
|
->label('Email')
|
|
->nullable(),
|
|
TextInput::make('headmaster_name')
|
|
->label('Nama Kepala Sekolah')
|
|
->nullable(),
|
|
TextInput::make('headmaster_nip')
|
|
->label('NIP Kepala Sekolah')
|
|
->nullable(),
|
|
TextInput::make('phase')
|
|
->label('Fase')
|
|
->nullable(),
|
|
])
|
|
])
|
|
->model($this->record)
|
|
->statePath('data');
|
|
}
|
|
|
|
public function save(): void
|
|
{
|
|
$this->record->fill($this->data)->save();
|
|
Notification::make()
|
|
->title('Success')
|
|
->body('Data saved successfully.')
|
|
->success()
|
|
->send();
|
|
}
|
|
}
|