MorphTo

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.
The key is a reference to the model, and the value is the field to display.