form->fill([ 'name' => $this->course->name, 'slug' => $this->course->slug, ]); } protected function getFormSchema(): array { return [ TextInput::make('name') ->label('Название курса') ->required() ->reactive() ->afterStateUpdated(function (Closure $set, $state) { $set('slug', Str::slug($state)); }), TextInput::make('slug')->label('Название в url-ссылке'), ]; } protected function getFormModel(): Course { return $this->course; } public function save(): void { $this->course->update( $this->form->getState(), ); } public function createLesson() { return redirect()->route('lesson-create', ['course' => $this->course]); } protected function getTableQuery() { return Lesson::query()->where('course_id', $this->course->id); } protected function getTableColumns(): array { return [ TextColumn::make('name'), ]; } protected function getTableActions(): array { return [ Action::make('watch')->label('Посмотреть')->color('secondary') ->url(fn (Lesson $record): string => route('lesson', [ 'course' => $this->course, 'lesson' => $record->slug ])), Action::make('edit')->label('Редактировать') ->url(fn (Lesson $record): string => route('lesson-edit', [ 'course' => $this->course, 'lesson' => $record->slug ])), Action::make('delete')->label('Удалить')->color('danger') ->action(function (Lesson $record) { return $record->delete(); }), ]; } public function render() { return view('livewire.course.course-edit')->layout('layouts.base'); } }