epartment / nova-dependency-container

A Laravel Nova field container allowing to depend on other fields values
MIT License
382 stars 163 forks source link

Docs: MorphTo, singularLabel and dependency container #207

Open preliot opened 2 years ago

preliot commented 2 years ago

Suggestion for improvement of documentation for MorphTo field:

If you want to depend on morphTo and use singularLabel() on your Nova resources, the dependency won't work if you follow documentation. The solution is you must depend on the singular label (and not the Model/Class name).

Example:

MorphTo::make('Commentable')->types([
    Post::class,
    Video::class,
]),

NovaDependencyContainer::make([
    Text::make('Additional Text', 'additional'),
    Boolean::make('Visible', 'visible')
])
->dependsOn('commentable', Post::singularLabel())