Extends
BelongsTo
* has the same features
MorphTo relationship field in Laravel
Same as MoonShine\Fields\Relationships\BelongsTo
only for MorphTo relationships
use MoonShine\Fields\Relationships\MorphTo; //... public function fields(): array{ return [ MorphTo::make('Commentable')->types([ Article::class => 'title' ]), ];}//...
Required types
method indicating the available classes.
Description of the value of the types
method:
The key is a reference to the model
The value is a string or an array.
If the value is passed as a string, it should indicate the name of the field to be displayed. If it is passed as an array, then the first element of the array is the name of the field to display, and the second is the name of the relationship instead of the name of the model.
use MoonShine\Fields\Relationships\MorphTo; //... public function fields(): array{ return [ MorphTo::make('Imageable')->types([ Company::class => ['short_name', 'Organization'] ]), ];}//...