MorphTo

You're browsing the documentation for an old version of MoonShine. Consider upgrading your project to MoonShine 2.x.

Extends BelongsTo * has the same features

Relationship field in Laravel like MorphTo

Same as MoonShine\Fields\BelongsTo but for MorphTo relationships

use MoonShine\Fields\MorphTo;
 
//...
 
public function fields(): array
{
return [
MorphTo::make('Commentable')->types([
Article::class => 'title'
]),
];
}
//...

Required types method specifying the classes available.
The key is a reference to the model, and the value is the field to display.