max26292 / nova-mediable-manager
A Laravel Nova mediable manager tool and field.
v1.0.3
2023-06-23 05:03 UTC
Requires
- php: >=7.1.0
- intervention/image: ^2.5
- laravel/framework: ~5.8.0|^6.0|^7.0|^8.0
This package is auto-updated.
Last update: 2024-11-23 07:56:28 UTC
README
This package is still in heavy development, please dont use in production
Laravel Nova Media Manager and Field to manage Polymorphic ManyToMany Relationships.
Table of Contents
Install
composer require naska-it/nova-mediable-manager
php artisan vendor:publish --provider="NaskaIt\NovaMediableManager\ToolServiceProvider"
php artisan migrate
php artisan storage:link
Configuration
Check in config/nova-mediable-manager.php for some extra configuration Enable Manager add to app/Providers/NovaServiceProvider.php
/** * Get the tools that should be listed in the Nova sidebar. * * @return array */ public function tools() { return [ new \NaskaIt\NovaMediableManager\NovaMediableManager ]; }
Using Field - first add HasMedia trait to your model
use NaskaIt\NovaMediableManager\HasMedia; class Page extends Model { use HasMedia;
Using Field - Nova Resource
use NaskaIt\NovaMediableManager\Mediable; class Page extends Resource { /** * Get the fields displayed by the resource. * * @param \Illuminate\Http\Request $request * @return array */ public function fields(Request $request) { return [ ID::make(__('ID'), 'id')->sortable(), Text::make('Name'), Trix::make('Body'), Mediable::make('Image') ->hideFromIndex() ->isSingle(), Mediable::make('Featured') ->isSingle(), Mediable::make('Gallery'), ]; }
Flexible
If you use Mediable field inside Flexible Layout
use NaskaIt\NovaMediableManager\Mediable; public function fields() { return [ Text::make('Headline'), Text::make('Slogan'), Mediable::make('Block') ->isSingle() ->isFlexible(), ]; }
Add to your layout HasFlexibleMediable trait
use NaskaIt\NovaMediableManager\HasFlexibleMediable; class BlockLayout extends Layout { use HasFlexibleMediable;
Credits
Where I get some code from :)
Alternatives
What I was using Before