162 lines
5.5 KiB
PHP
162 lines
5.5 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('Full Name')
|
|
->required()
|
|
->maxLength(100),
|
|
|
|
Forms\Components\Select::make('gender')
|
|
->label('Gender')
|
|
->options([
|
|
'L' => 'L',
|
|
'P' => 'P',
|
|
])
|
|
->required(),
|
|
|
|
Forms\Components\DatePicker::make('birth_date')
|
|
->label('Birth Date')
|
|
->required(),
|
|
|
|
Forms\Components\TextInput::make('birth_place')
|
|
->label('Birth Place')
|
|
->required()
|
|
->maxLength(100),
|
|
|
|
Forms\Components\TextInput::make('phone')
|
|
->label('Phone')
|
|
->maxLength(15),
|
|
|
|
Forms\Components\TextInput::make('email')
|
|
->label("Parent's Email")
|
|
->email()
|
|
->required()
|
|
->maxLength(100),
|
|
|
|
Forms\Components\TextInput::make('parent_name')
|
|
->label("Parent's Name")
|
|
->required()
|
|
->maxLength(100),
|
|
|
|
Forms\Components\TextInput::make('parent_phone')
|
|
->label("Parent's Phone")
|
|
->required()
|
|
->maxLength(15),
|
|
|
|
Forms\Components\Select::make('religion')
|
|
->label('Religion')
|
|
->options([
|
|
'islam' => 'Islam',
|
|
'hindu' => 'Hindu',
|
|
'katolik' => 'Katolik',
|
|
'kristen' => 'Kristen',
|
|
'buddha' => 'Buddha',
|
|
]),
|
|
|
|
Forms\Components\Textarea::make('address')
|
|
->label('Address')
|
|
->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('Name')
|
|
->searchable()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('gender')
|
|
->label('Gender')
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('birth_place')
|
|
->label('Birth Place'),
|
|
Tables\Columns\TextColumn::make('birth_date')
|
|
->label('Birth Date')
|
|
->date(),
|
|
Tables\Columns\TextColumn::make('parent_name')
|
|
->label("Parent's Name"),
|
|
Tables\Columns\TextColumn::make('religion')
|
|
->label("Religion")
|
|
->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'),
|
|
];
|
|
}
|
|
}
|