Skip to content

A Laravel Nova field for displaying morphTo relationship inline.

License

Notifications You must be signed in to change notification settings

EP4/nova-inline-morph-to

 
 

Repository files navigation

Nova Inline MorphTo Field

Latest Version on Packagist Total Downloads License

Laravel Nova Inline MorphTo Field in action

Install

composer require digital-creative/nova-inline-morph-to

Usage

The signature is the same as the default MorphTo field that ships with Nova.

use DigitalCreative\InlineMorphTo\InlineMorphTo;
use DigitalCreative\InlineMorphTo\HasInlineMorphToFields;

class Article extends Resource
{
    use HasInlineMorphToFields;

    public function fields(Request $request)
    {
        return [
            ...
            InlineMorphTo::make('Template')
                         ->types([
                             \App\Nova\Video::class,
                             \App\Nova\Image::class,
                             \App\Nova\Text::class,
                             \App\Nova\Gallery::class,
                         ])
                         ->default(\App\Nova\Text::class),
            ...
        ];

    }
}

Note: You will need to import the HasInlineMorphToFields trait for this field to display correctly within resource detail views.

Code example: adding morphables dynamically from a directory #4

License

The MIT License (MIT). Please see License File for more information.

About

A Laravel Nova field for displaying morphTo relationship inline.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 65.0%
  • Vue 30.6%
  • JavaScript 4.4%