components([ Section::make('Informasi Tugas') ->schema([ TextInput::make('title') ->label('Judul') ->placeholder('Tugas Pemrograman Web') ->autocomplete(false) ->required() ->maxLength(100) ->minLength(3) ->autofocus() ->columnSpanFull(), Grid::make(3) ->schema([ Select::make('course_id') ->label('Mata Kuliah') ->options(function () { return Course::query() ->where('semester', app(GeneralSettings::class)->current_semester) ->pluck('name', 'id') ->toArray(); }) ->searchable() ->live() ->required(), DateTimePicker::make('due_date') ->label('Batas Waktu') ->placeholder('Pilih Tanggal & Waktu') ->required() ->native(false) ->displayFormat('l, d F Y H:i'), Select::make('type') ->label('Tipe Tugas') ->options(AssignmentType::class) ->required() ->native(false) ->default(AssignmentType::Individual->value) ->live() ->afterStateUpdated(function (Set $set) { $set('student_ids', []); $set('study_group_ids', []); }), ]) ->columnSpanFull(), RichEditor::make('description') ->label('Deskripsi') ->placeholder('Buatlah program web yang dapat melakukan ...') ->nullable() ->columnSpanFull(), AdvancedFileUpload::make('pdf') ->label('Lampiran PDF') ->pdfPreviewHeight(400) ->pdfDisplayPage(1) ->pdfToolbar(true) ->pdfZoomLevel(100) ->pdfFitType(PdfViewFit::FIT) ->pdfNavPanes(true) ->disk(config('filesystems.default')) ->acceptedFileTypes(['application/pdf']) ->maxSize(1024 * 5) ->directory('assignments/'.now()->toDateString()) ->nullable() ->columnSpanFull(), ]) ->columns(2), Section::make('Target Penugasan') ->schema([ Select::make('student_ids') ->label('Mahasiswa') ->options(Student::pluck('full_name', 'id')) ->multiple() ->searchable() ->preload() ->native(false) ->hintAction(SelectAllStudentsAction::make()) ->helperText('Pilih mahasiswa yang menjadi target tugas ini.') ->columnSpanFull() ->hidden(fn (Get $get) => in_array($get('type'), [AssignmentType::Group, AssignmentType::Group->value])) ->required(fn (Get $get) => ! in_array($get('type'), [AssignmentType::Group, AssignmentType::Group->value])), Callout::make('Penugasan Kelompok Otomatis') ->description('Tugas ini akan otomatis ditujukan ke SEMUA kelompok belajar pada mata kuliah ini.') ->info() ->columnSpanFull() ->visible(fn (Get $get) => in_array($get('type'), [AssignmentType::Group, AssignmentType::Group->value])), ]), ]) ->columns(1); } }