refactor: remove CreateSessionAction and AttendanceRelationManager to streamline class session management
This commit is contained in:
parent
e14f402322
commit
b2c8355e38
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Learning\ClassSessions\Actions;
|
||||
|
||||
use App\Filament\Actions\Cheerful\CreateAction;
|
||||
use Filament\Support\Enums\Width;
|
||||
|
||||
class CreateSessionAction extends CreateAction
|
||||
{
|
||||
public static function getDefaultName(): ?string
|
||||
{
|
||||
return 'createSession';
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->label('Tambah')
|
||||
->modalHeading('Tambah Sesi')
|
||||
->modalSubmitActionLabel('Simpan')
|
||||
->modalCancelActionLabel('Batal')
|
||||
->schema(function ($schema, $livewire) {
|
||||
return $livewire->form($schema);
|
||||
})
|
||||
->mutateDataUsing(function (array $data, $livewire): array {
|
||||
$data['course_id'] = $livewire->courseId;
|
||||
|
||||
return $data;
|
||||
})
|
||||
->extraModalFooterActions(fn (CreateAction $action): array => [
|
||||
$action->makeModalSubmitAction('createAnother', arguments: ['another' => true])
|
||||
->label('Simpan dan Tambah Lagi'),
|
||||
])
|
||||
->modalWidth(Width::TwoExtraLarge);
|
||||
}
|
||||
}
|
||||
@ -3,7 +3,6 @@
|
||||
namespace App\Filament\Resources\Learning\ClassSessions\Pages;
|
||||
|
||||
use App\Filament\Actions\BackAction;
|
||||
use App\Filament\Resources\Learning\ClassSessions\Actions\CreateSessionAction;
|
||||
use App\Filament\Resources\Learning\ClassSessions\Actions\DeleteSessionAction;
|
||||
use App\Filament\Resources\Learning\ClassSessions\Actions\EditSessionAction;
|
||||
use App\Filament\Resources\Learning\ClassSessions\Actions\GenerateSessionsAction;
|
||||
@ -134,8 +133,6 @@ protected function getHeaderActions(): array
|
||||
->url(ManageClassSessions::getUrl()),
|
||||
|
||||
GenerateSessionsAction::make(),
|
||||
|
||||
CreateSessionAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -1,93 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Learning\ClassSessions\RelationManagers;
|
||||
|
||||
use App\Filament\Actions\Cheerful\CreateAction;
|
||||
use App\Filament\Actions\Cheerful\DeleteAction;
|
||||
use App\Filament\Actions\Cheerful\EditAction;
|
||||
use App\Filament\Actions\DefaultBulkActions;
|
||||
use App\Filament\Columns\RowIndexColumn;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class AttendanceRelationManager extends RelationManager
|
||||
{
|
||||
protected static string $relationship = 'attendances';
|
||||
|
||||
protected static ?string $title = 'Presensi Mahasiswa';
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Select::make('student_id')
|
||||
->label('Mahasiswa')
|
||||
->placeholder('Pilih Mahasiswa')
|
||||
->relationship('student', 'full_name')
|
||||
->searchable()
|
||||
->required()
|
||||
->preload()
|
||||
->helperText('Pilih mahasiswa yang hadir pada pertemuan ini.'),
|
||||
|
||||
DateTimePicker::make('attended_at')
|
||||
->label('Waktu Presensi')
|
||||
->default(now())
|
||||
->native(false)
|
||||
->helperText('Tanggal dan jam mahasiswa melakukan presensi.'),
|
||||
])
|
||||
->columns(1);
|
||||
}
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->recordTitleAttribute('student.full_name')
|
||||
->columns([
|
||||
...RowIndexColumn::make(),
|
||||
|
||||
TextColumn::make('student.student_number')
|
||||
->label('NIM')
|
||||
->copyable()
|
||||
->searchable()
|
||||
->sortable()
|
||||
->color('gray'),
|
||||
|
||||
TextColumn::make('student.full_name')
|
||||
->label('Nama Mahasiswa')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('attended_at')
|
||||
->label('Waktu Presensi')
|
||||
->dateTime('l, d F Y H:i')
|
||||
->sortable()
|
||||
->description(fn ($record) => $record->attended_at->format('H:i').' WIB')
|
||||
->color('primary'),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->headerActions([
|
||||
CreateAction::make()
|
||||
->modalWidth(Width::Large),
|
||||
])
|
||||
->actions([
|
||||
EditAction::make()
|
||||
->modalWidth(Width::Large),
|
||||
|
||||
DeleteAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
...DefaultBulkActions::make('Presensi Mahasiswa'),
|
||||
]),
|
||||
])
|
||||
->emptyStateDescription('Belum ada data presensi untuk pertemuan ini.');
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user