Отношение content() может быть связаны с различными моделями: LiveTraffic, SimulatedFlight или Video.
LiveTraffic и SimulatedFlight по существу модели Пито и, соответственно, имеют отношение track() HasMany и отношение Prompts() HasMany.
Для простоты я возьму только случай LiveTraffic content_type.
В ChaptersRelationManager у меня есть следующее:
Код: Выделить всё
public function form(Form $form): Form
{
return $form
->schema([
...
Select::make('content_type')
->options(Chapter::getContentTypesAsOptions())
->required()
->in(Chapter::getContentTypesAliases()),
Group::make()
->relationship('content')
->schema(fn (Get $get): array => match ($get('content_type')) {
(new LiveTraffic)->getMorphClass() => $this->liveTrafficSchema(),
(new SimulatedFlight)->getMorphClass() => $this->simulatedFlightSchema(),
(new Video)->getMorphClass() => $this->videoSchema(),
default => [],
}),
]);
}
protected function liveTrafficSchema(): array|Closure
{
return [
Repeater::make('tracks')
->relationship('tracks')
->defaultItems(1)
->schema([
MarkdownEditor::make('transcript')
->required(),
]),
];
}
Код: Выделить всё
BadMethodCallException
Call to undefined method App\Models\Chapter::tracks()
Код: Выделить всё
protected function liveTrafficSchema(): array|Closure
{
return [
TextInput::make('test'),
];
}
Код: Выделить всё
MassAssignmentException
Add [test] to fillable property to allow mass assignment on [App\Models\LiveTraffic].
Подробнее здесь: https://stackoverflow.com/questions/792 ... ament-form
Мобильная версия