118 lines
3.3 KiB
PHP
118 lines
3.3 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
use App\Filament\Resources\SubjectResource\Pages;
|
|
use App\Filament\Resources\SubjectResource\RelationManagers;
|
|
use App\Models\Subject;
|
|
use Filament\Forms;
|
|
use Filament\Forms\Form;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Table;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
|
|
|
class SubjectResource extends Resource
|
|
{
|
|
protected static ?string $model = Subject::class;
|
|
|
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
|
|
|
protected static ?string $navigationGroup = 'Data Master';
|
|
|
|
public static function form(Form $form): Form
|
|
{
|
|
return $form
|
|
->schema([
|
|
Forms\Components\TextInput::make('name')
|
|
->label('Nama Mapel')
|
|
->required()
|
|
->maxLength(255),
|
|
|
|
Forms\Components\Toggle::make('is_religious')
|
|
->label('Religious')
|
|
->required(),
|
|
|
|
Forms\Components\Select::make('category')
|
|
->label('Kategori')
|
|
->options([
|
|
'umum' => 'Umum',
|
|
'muatan lokal' => 'Muatan Lokal',
|
|
'seni' => 'Seni',
|
|
])
|
|
->required(),
|
|
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
Tables\Columns\TextColumn::make('name')
|
|
->label("Nama")
|
|
->searchable(),
|
|
Tables\Columns\IconColumn::make('is_religious')
|
|
->label("Is Religious")
|
|
->boolean(),
|
|
Tables\Columns\TextColumn::make('category')
|
|
->label("Kategori")
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('created_at')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
Tables\Columns\TextColumn::make('updated_at')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
])
|
|
->filters([
|
|
//
|
|
])
|
|
->actions([
|
|
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\ListSubjects::route('/'),
|
|
'create' => Pages\CreateSubject::route('/create'),
|
|
'edit' => Pages\EditSubject::route('/{record}/edit'),
|
|
];
|
|
}
|
|
|
|
public static function getNavigationLabel(): string
|
|
{
|
|
return 'Mata Pelajaran';
|
|
}
|
|
|
|
public static function getBreadcrumb(): string
|
|
{
|
|
return 'Mata Pelajaran';
|
|
}
|
|
|
|
public static function getPluralModelLabel(): string
|
|
{
|
|
return 'Mata Pelajaran';
|
|
}
|
|
}
|