100 lines
3.1 KiB
PHP
100 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
use App\Filament\Resources\StudentActivitiesResource\Pages;
|
|
use App\Filament\Resources\StudentActivitiesResource\RelationManagers;
|
|
use App\Models\StudentActivities;
|
|
use Filament\Forms;
|
|
use Filament\Forms\Components\Card;
|
|
use Filament\Forms\Components\RichEditor;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Forms\Form;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Filters\Filter;
|
|
use Filament\Tables\Table;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
|
|
|
class StudentActivitiesResource extends Resource
|
|
{
|
|
protected static ?string $model = StudentActivities::class;
|
|
|
|
protected static ?string $navigationIcon = 'heroicon-o-bell-alert';
|
|
protected static ?string $navigationLabel = 'Kegiatan Siswa';
|
|
protected static ?string $pluralLabel = 'Kegiatan Siswa';
|
|
protected static ?string $modelLabel = 'Kegiatan Siswa';
|
|
protected static ?string $slug = 'kegiatan-siswa';
|
|
|
|
public static function form(Form $form): Form
|
|
{
|
|
return $form
|
|
->schema([
|
|
Card::make()
|
|
->schema([
|
|
TextInput::make('name')
|
|
->label('Nama Kegiatan')
|
|
->required()
|
|
->maxLength(255),
|
|
|
|
RichEditor::make('description')
|
|
->label('Deskripsi Kegiatan')
|
|
->required()
|
|
->maxLength(65535)
|
|
->columnSpanFull(),
|
|
])
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('name')
|
|
->label('Nama Kegiatan')
|
|
->searchable()
|
|
->sortable(),
|
|
|
|
TextColumn::make('created_at')
|
|
->label('Diupload')
|
|
->dateTime()
|
|
->badge()
|
|
->colors(['success'])
|
|
->sortable(),
|
|
])
|
|
->filters([
|
|
Filter::make('Kegiatan Terbaru')
|
|
->query(fn (Builder $query) => $query->orderBy('created_at', 'desc'))
|
|
->label('Kegiatan Terbaru'),
|
|
])
|
|
->actions([
|
|
Tables\Actions\ViewAction::make(),
|
|
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\ListStudentActivities::route('/'),
|
|
'create' => Pages\CreateStudentActivities::route('/create'),
|
|
'edit' => Pages\EditStudentActivities::route('/{record}/edit'),
|
|
];
|
|
}
|
|
}
|