stepanenko3 / nova-media-field

A Laravel Nova field for laravel-medilibrary.
MIT License
15 stars 6 forks source link

Nova Media Field

Latest Version on Packagist Total Downloads License

screenshot of field

Description

A Laravel Nova field for laravel-medilibrary.

Features

Requirements

Installation

# Install the package
composer require stepanenko3/nova-media-field

Usage

use use Stepanenko3\NovaMediaField\Fields\Media;
...

Media::make(__('Image'), 'image'), // Single image. Auto detect from collection

Media::make(__('Images'), 'images'), // Multiple images. Auto detect from collection

// Validation rules

Media::make('Images', 'images')
    ->rules(['required', 'array', 'max:4'])
    ->singleMediaRules(['image', 'max:80']),

// Custom properties with validtion

Media::make('Images', 'images')
    ->customPropertiesFields([
        Boolean::make('Active', 'active')
            ->rules(['boolean']),

        Markdown::make('Description', 'description')
            ->rules(['max:1000']),
    ])

// Count images displayed on index

Media::make('Images', 'images')
    ->countOfImagesDisplayedOnIndex(2),

// Full example

Media::make('Images', 'images')
    ->customPropertiesFields([
        Boolean::make('Active', 'active')
            ->rules(['boolean']),

        Markdown::make('Description', 'description')
            ->rules(['max:1000']),
    ])
    ->countOfImagesDisplayedOnIndex(2)
    ->rules(['required', 'array', 'max:4'])
    ->singleMediaRules(['image', 'max:80']),

Usage with File Manager

Install stepanenko3/nova-filemanager

compore require stepanenko3/nova-filemanager

Register Service provider

// app/Providers/NovaServiceProvider.php

public function tools(): array
{
    return [
        new Stepanenko3\NovaFileManager\FileManagerTool,
    ];
}

Use Media field with File Manager

Media::make(__('Image'), 'image')
    ->fileManager(),

Screenshots

screenshot of field screenshot of field screenshot of field screenshot of field screenshot of field screenshot of field

Credits

Contributing

Thank you for considering contributing to this package! Please create a pull request with your contributions with detailed explanation of the changes you are proposing.

License

This package is open-sourced software licensed under the MIT license.