schema([ Section::make() ->schema([ Forms\Components\Grid::make(2)->schema([ Select::make('educational_group_id')->options(EducationalGroup::all()->pluck('title', 'id')) ->live() ->label('Выбрать группу') ->required(), // TextInput::make('title') // ->live() // ->label('Заголовок')->required(), // Select::make('type')->options([ // 'schedule' => 'Обычное расписание', // 'interval' => 'Временное расписание', // 'exam' => 'Промежуточная аттестация', // ])->label('Тип расписания')->required()->live(), Forms\Components\Toggle::make('is_zaoch')->label('Очная|Заочная')->inline(false), ]), // Forms\Components\Repeater::make('days')->label('')->schema([ // Forms\Components\Repeater::make('form')->label('')->schema([ // Forms\Components\Repeater::make('weeks')->label('')->schema([ // Forms\Components\Repeater::make('lesson_info')->label('')->schema([ // TextInput::make('title')->label('Название-пары'), // TextInput::make('teacher')->label('Преподаватель'), // TextInput::make('studyRoom')->label('Кабинет') // ])->live()->maxItems(2)->collapsed()->addActionLabel('Добавить подгруппу')->columns(3) // ->itemLabel(function (Get $get, $state) { // static $count = 1; // if (count($get('lesson_info')) === 1) { // return "Общая группа"; // } else { // $nmb = $count++ % 2 == 0 ? 2 : 1; // return "Подгруппа " . $nmb; } // }), // ])->maxItems(2)->addActionLabel('Добавить четную/нечетную неделю') // ->itemLabel(function (Get $get) { // static $position = 0; // if (count($get('weeks')) === 1) { // return "Общая неделя"; // } else { // $nmb = $position++ % 2 == 0 ? 0 : 1; // return self::$typeWeek[$nmb] . " неделя"; // } // }) // ->collapsed() // ]) // ->maxItems(5) // ->itemLabel(function (Get $get) { // static $count = 0; // $maxCount = count($get('form')); // $count = ($count++ <= $maxCount) ? $count : 1; // return "Пара #" . $count; // }) // ->addActionLabel('Добавить пару'), // ])->maxItems(6)->minItems(1)->itemLabel(function ($state) { // static $position = 0; // return self::$weekDays[$position++]; // })->addActionLabel('Добавить день недели')->collapsed()->defaultItems(6)->hidden(function (callable $get) { // if ($get('type') === 'schedule' || $get('type') === 'interval') { // return false; // } else { // return true; // } // }), ]), Section::make() ->schema([ Forms\Components\Repeater::make('file')->schema([ TextInput::make('title') ->required() ->maxLength(255) ->autofocus(), FileUpload::make('path') ->required() ->getUploadedFileNameForStorageUsing( fn (TemporaryUploadedFile $file): string => str(Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME) . '-' . Carbon::now()->timestamp ) . '.' . $file->getClientOriginalExtension()) ) ->acceptedFileTypes([ 'application/pdf', ]) ->maxSize(512000) ->disk('public') ->directory('files') ->downloadable() ->afterStateUpdated(function ($set, $state) { $set('title', pathinfo($state?->getClientOriginalName(), PATHINFO_FILENAME)); }) ->visibility('public') ]), ]) ]); } public static function table(Table $table): Table { return $table ->columns([ Tables\Columns\TextColumn::make('title'), Tables\Columns\TextColumn::make('type'), IconColumn::make('is_zaoch') ->boolean(), ]) ->filters([ // ]) ->actions([ Tables\Actions\EditAction::make(), ]) ->bulkActions([ Tables\Actions\BulkActionGroup::make([ Tables\Actions\DeleteBulkAction::make(), ]), ]); } public static function getRelations(): array { return [ // ]; } public static function getPages(): array { return [ 'index' => Pages\ListSchedules::route('/'), 'create' => Pages\CreateSchedule::route('/create'), 'edit' => Pages\EditSchedule::route('/{record}/edit'), ]; } }