114 lines
3.8 KiB
PHP
114 lines
3.8 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
use App\Filament\Resources\ClassSubjectResource\Pages;
|
|
use App\Filament\Resources\ClassSubjectResource\RelationManagers;
|
|
use App\Models\ClassRoom;
|
|
use App\Models\ClassSubject;
|
|
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;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
|
|
class ClassSubjectResource extends Resource
|
|
{
|
|
protected static ?string $model = ClassSubject::class;
|
|
|
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
|
|
|
protected static ?string $navigationGroup = 'Academic Setup';
|
|
|
|
public static function form(Form $form): Form
|
|
{
|
|
return $form
|
|
->schema([
|
|
Select::make('class_room_id')
|
|
->label('Kelas')
|
|
->relationship('class', 'class_name')
|
|
->required(),
|
|
|
|
Select::make('subject_id')
|
|
->label('Mata Pelajaran')
|
|
->relationship('subject', 'name')
|
|
->required(),
|
|
|
|
Select::make('academic_year_id')
|
|
->label('Tahun Ajaran')
|
|
->relationship('academicYear', 'name') // ganti "name" jika kolomnya berbeda
|
|
->required(),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('class.class_name')->label('Kelas')->sortable()->searchable(),
|
|
TextColumn::make('subject.name')->label('Mata Pelajaran')->sortable()->searchable(),
|
|
|
|
Tables\Columns\TextColumn::make('created_at')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
Tables\Columns\TextColumn::make('updated_at')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
Tables\Columns\TextColumn::make('deleted_at') // Add this column to show deleted timestamp
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
])
|
|
->filters([
|
|
Tables\Filters\TrashedFilter::make()->label('Tampilkan Data yang Dihapus'),
|
|
])
|
|
->actions([
|
|
Tables\Actions\EditAction::make()->visible(fn () => auth()->user()->hasRole('admin')),
|
|
Tables\Actions\DeleteAction::make()->visible(fn () => auth()->user()->hasRole('admin')),
|
|
Tables\Actions\RestoreAction::make()->visible(fn (ClassSubject $record) => auth()->user()->hasRole('admin') && $record->trashed()),
|
|
])
|
|
->bulkActions([
|
|
Tables\Actions\BulkActionGroup::make([
|
|
Tables\Actions\DeleteBulkAction::make()->visible(fn () => auth()->user()->hasRole('admin')),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public static function getRelations(): array
|
|
{
|
|
return [
|
|
//
|
|
];
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => Pages\ListClassSubjects::route('/'),
|
|
'create' => Pages\CreateClassSubject::route('/create'),
|
|
'edit' => Pages\EditClassSubject::route('/{record}/edit'),
|
|
];
|
|
}
|
|
|
|
public static function getNavigationLabel(): string
|
|
{
|
|
return 'Mata Pelajaran per-Kelas';
|
|
}
|
|
|
|
public static function getBreadcrumb(): string
|
|
{
|
|
return 'Mata Pelajaran per-Kelas';
|
|
}
|
|
|
|
public static function getPluralModelLabel(): string
|
|
{
|
|
return 'Mata Pelajaran per-Kelas';
|
|
}
|
|
}
|