86 lines
2.5 KiB
PHP
86 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
use Filament\Forms;
|
|
use Filament\Tables;
|
|
use Filament\Forms\Form;
|
|
use App\Models\Classroom;
|
|
use Filament\Tables\Table;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Forms\Components\Card;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use App\Filament\Resources\ClassroomResource\Pages;
|
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
|
use App\Filament\Resources\ClassroomResource\RelationManagers;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
|
|
class ClassroomResource extends Resource
|
|
{
|
|
protected static ?string $model = Classroom::class;
|
|
|
|
protected static ?string $navigationIcon = 'heroicon-o-building-office';
|
|
protected static ?string $navigationLabel = 'Kelas';
|
|
protected static ?string $pluralLabel = 'Kelas';
|
|
protected static ?string $modelLabel = 'Kelas';
|
|
protected static ?string $slug = 'kelas';
|
|
|
|
public static function form(Form $form): Form
|
|
{
|
|
return $form
|
|
->schema([
|
|
Card::make()
|
|
->schema([
|
|
TextInput::make('name')
|
|
->label('Nama Kelas')
|
|
->required()
|
|
->placeholder('Masukkan nama kelas, max : 50 karakter')
|
|
->maxLength(50)
|
|
->unique(ignorable: fn (?Classroom $record) => $record),
|
|
])
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('name')
|
|
->label('Kelas')
|
|
->searchable()
|
|
->badge()
|
|
->colors(['primary'])
|
|
->sortable(),
|
|
])
|
|
->filters([
|
|
//
|
|
])
|
|
->actions([
|
|
Tables\Actions\EditAction::make(),
|
|
Tables\Actions\DeleteAction::make(),
|
|
])
|
|
->bulkActions([
|
|
Tables\Actions\BulkActionGroup::make([
|
|
Tables\Actions\DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public static function getRelations(): array
|
|
{
|
|
return [
|
|
//
|
|
];
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => Pages\ListClassrooms::route('/'),
|
|
'create' => Pages\CreateClassroom::route('/create'),
|
|
'edit' => Pages\EditClassroom::route('/{record}/edit'),
|
|
];
|
|
}
|
|
}
|