177 lines
5.8 KiB
PHP
177 lines
5.8 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
use App\Filament\Resources\StudentResource\Pages;
|
|
use App\Models\ClassRoom;
|
|
use App\Models\Student;
|
|
use Filament\Forms;
|
|
use Filament\Forms\Form;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Table;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
class StudentResource extends Resource
|
|
{
|
|
protected static ?string $model = Student::class;
|
|
|
|
protected static ?string $navigationIcon = 'heroicon-o-users';
|
|
|
|
protected static ?string $navigationGroup = 'Data Master';
|
|
|
|
public static function form(Form $form): Form
|
|
{
|
|
return $form
|
|
->schema([
|
|
Forms\Components\Section::make('Data Siswa')
|
|
->schema([
|
|
Forms\Components\TextInput::make('nisn')
|
|
->label('NISN')
|
|
->maxLength(20),
|
|
|
|
Forms\Components\TextInput::make('nis')
|
|
->label('NIS')
|
|
->required()
|
|
->maxLength(20),
|
|
|
|
Forms\Components\TextInput::make('full_name')
|
|
->label('Nama Lengkap')
|
|
->required()
|
|
->maxLength(100),
|
|
|
|
Forms\Components\Select::make('gender')
|
|
->label('Jenis Kelamin')
|
|
->options([
|
|
'L' => 'L',
|
|
'P' => 'P',
|
|
])
|
|
->required(),
|
|
|
|
Forms\Components\DatePicker::make('birth_date')
|
|
->label('Tanggal Lahir')
|
|
->required(),
|
|
|
|
Forms\Components\TextInput::make('birth_place')
|
|
->label('Tempat Lahir')
|
|
->required()
|
|
->maxLength(100),
|
|
|
|
Forms\Components\TextInput::make('phone')
|
|
->label('Nomor Telepon')
|
|
->maxLength(15),
|
|
|
|
Forms\Components\TextInput::make('email')
|
|
->label("Email Orang Tua")
|
|
->email()
|
|
->required()
|
|
->maxLength(100),
|
|
|
|
Forms\Components\TextInput::make('parent_name')
|
|
->label("Nama Orang Tua")
|
|
->required()
|
|
->maxLength(100),
|
|
|
|
Forms\Components\TextInput::make('parent_phone')
|
|
->label("Nomor Telepon Orang Tua")
|
|
->required()
|
|
->maxLength(15),
|
|
|
|
Forms\Components\Select::make('religion')
|
|
->label('Agama')
|
|
->options([
|
|
'islam' => 'Islam',
|
|
'hindu' => 'Hindu',
|
|
'katolik' => 'Katolik',
|
|
'kristen' => 'Kristen',
|
|
'buddha' => 'Buddha',
|
|
]),
|
|
|
|
Forms\Components\Textarea::make('address')
|
|
->label('Alamat')
|
|
->rows(1),
|
|
|
|
])
|
|
->columns(2),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
Tables\Columns\TextColumn::make('nis')
|
|
->label('NIS')
|
|
->searchable(),
|
|
Tables\Columns\TextColumn::make('full_name')
|
|
->label('Nama')
|
|
->searchable()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('gender')
|
|
->label('Jenis Kelamin')
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('birth_place')
|
|
->label('Tempat Lahir'),
|
|
Tables\Columns\TextColumn::make('birth_date')
|
|
->label('Tanggal Lahir')
|
|
->date(),
|
|
Tables\Columns\TextColumn::make('parent_name')
|
|
->label("Nama Orang Tua"),
|
|
Tables\Columns\TextColumn::make('religion')
|
|
->label("Agama")
|
|
->formatStateUsing(fn (string $state): string => strtoupper($state))
|
|
->badge(),
|
|
Tables\Columns\TextColumn::make('created_at')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
])
|
|
->filters([
|
|
//
|
|
])
|
|
->actions([
|
|
Tables\Actions\ViewAction::make(),
|
|
Tables\Actions\EditAction::make(),
|
|
])
|
|
->bulkActions([
|
|
Tables\Actions\BulkActionGroup::make([
|
|
Tables\Actions\DeleteBulkAction::make(),
|
|
]),
|
|
])
|
|
->emptyStateActions([
|
|
Tables\Actions\CreateAction::make(),
|
|
]);
|
|
}
|
|
|
|
public static function getRelations(): array
|
|
{
|
|
return [
|
|
//
|
|
];
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => Pages\ListStudents::route('/'),
|
|
'create' => Pages\CreateStudent::route('/create'),
|
|
'edit' => Pages\EditStudent::route('/{record}/edit'),
|
|
];
|
|
}
|
|
|
|
public static function getNavigationLabel(): string
|
|
{
|
|
return 'Siswa';
|
|
}
|
|
|
|
public static function getBreadcrumb(): string
|
|
{
|
|
return 'Siswa';
|
|
}
|
|
|
|
public static function getPluralModelLabel(): string
|
|
{
|
|
return 'Siswa';
|
|
}
|
|
}
|