GithubHelp home page GithubHelp logo

poolitclub / nova-media-hub Goto Github PK

View Code? Open in Web Editor NEW

This project forked from outl1ne/nova-media-hub

0.0 0.0 0.0 1.86 MB

This Laravel Nova package allows you to manage media and media fields.

License: MIT License

JavaScript 5.18% PHP 48.96% CSS 0.75% Vue 45.12%

nova-media-hub's Introduction

Nova Media Hub

Latest Version on Packagist Total Downloads

This Laravel Nova package allows you to manage media and media fields.

Requirements

  • php: >=8.0
  • laravel/nova: ^4.0

Features

  • Media Hub UI in separate view
  • Media Hub field for selecting single/multiple media
  • Image optimization and multiple conversions support
  • File naming and path making customization
  • Dark mode support
  • A lot configuration options

Screenshots

Media Hub

Choose media

Installation

Install the package in a Laravel Nova project via Composer and run migrations:

# Install nova-media-hub
composer require outl1ne/nova-media-hub

# Run migrations
php artisan migrate

Register the tool with Nova in the tools() method of the NovaServiceProvider:

// in app/Providers/NovaServiceProvider.php

public function tools()
{
    return [
        // ...
        \Outl1ne\NovaMediaHub\MediaHub::make()
        // You can choose to hide the Tool from the sidebar
          ->hideFromMenu()

          // Optionally add additional fields to Media items
          ->withCustomFields(
            ['copyright' => __('Copyright')],
            overwrite: false
          )
    ];
}

Usage

Fields

This package provides a field MediaHubField which allows you to select media. This saves the media as a JSON array into the database.

Example usage:

use Outl1ne\NovaMediaHub\Nova\Fields\MediaHubField;

// ...

MediaHubField::make('Media', 'media')
  ->defaultCollection('products') // Define the default collection the "Choose media" modal shows
  ->multiple(), // Define whether multiple media can be selected

Casting

The media column of models can be automatically cast as a Collection of Media models:

class Product extends Model
{
    protected $casts = [
        'media' => \Outl1ne\NovaMediaHub\Casts\MediaCast::class,
    ];
}
    $cover = Product::first()->media->first();

    // ...

    $urls = Product::first()->media->pluck('url');

    // ...

    $collection = Product::first()->media->where('collection_name', 'Details');

Configure

The config file can be published using the following command:

php artisan vendor:publish --provider="Outl1ne\NovaMediaHub\MediaHubServiceProvider" --tag="config"

Localization

The translation file(s) can be published by using the following command:

php artisan vendor:publish --provider="Outl1ne\NovaMediaHub\MediaHubServiceProvider" --tag="translations"

Credits

License

Nova Media Hub is open-sourced software licensed under the MIT license.

nova-media-hub's People

Contributors

tarpsvo avatar kasparrosin avatar murdercode avatar vodnicearv avatar trippo avatar poolitclub avatar faridaghili avatar richard-raadi avatar allantatter avatar nullthoughts avatar michalsrodek avatar ribesalexandre avatar stejaysulli avatar robindrost avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.