where('guide_id', $this->getOwnerRecord()->id); } public function getTreeRecordTitle(?Model $record = null): string { if (!$record) { return ''; } $prefix = $record->branch_option ? "[{$record->branch_option}] " : ''; $suffix = !empty($record->options) ? ' 📋' : ''; return $prefix . $record->title . $suffix; } protected function getFormSchema(): array { return [ Forms\Components\TextInput::make('page_number') ->label('页码') ->numeric() ->minValue(1), Forms\Components\TextInput::make('title') ->label('页面标题') ->required() ->maxLength(255), Forms\Components\TextInput::make('html_url') ->label('HTML页面URL') ->required() ->url() ->maxLength(500), Forms\Components\TagsInput::make('options') ->label('选项按钮') ->helperText('此页面展示的选项按钮,如"前门12"、"后门"。留空=无分支。'), Forms\Components\TextInput::make('branch_option') ->label('所属分支选项') ->maxLength(100) ->helperText('此页面对应父页面的哪个选项值(根页面留空)'), ]; } protected function getTreeActions(): array { return [ Actions\ViewAction::make(), Actions\EditAction::make()->slideOver(), Actions\DeleteAction::make(), ]; } protected function mutateFormDataBeforeCreate(array $data): array { $data['guide_id'] = $this->getOwnerRecord()->id; return $data; } protected function getOwnerRecord(): Guide { return Guide::findOrFail(request()->route('record')); } }