Coder Social home page Coder Social logo

array-images's Introduction

Laravel Nova Field - Array Images

A laravel nova field that will let you save your uploaded images path to your database in array format.

Installation

composer require halimtuhu/array-images

Usage

Create array images just call Halimtuhu\ArrayImages\ArrayImages class and use make static method to create a field.

...
use Halimtuhu\ArrayImages\ArrayImages;
...
public function fields(Request $request)
    {
        return [
            ...
            ArrayImages::make('Images', 'images'),
            ...
        ];
    }
...

That will create a field with name Images. Stored data will look like this.

[{
    "url": "http://laranov.halimtuhu.test/storage/wB04AbprHGxHw4I3sizXmuw9L4LBcG0wv0QEacAo.jpeg",
    "name": "wB04AbprHGxHw4I3sizXmuw9L4LBcG0wv0QEacAo.jpeg"
}, {
    "url": "http://laranov.halimtuhu.test/storage/eOuxUCjHGNokkHdOXYB7gGObxCvf7m30ridFpBpy.jpeg",
    "name": "eOuxUCjHGNokkHdOXYB7gGObxCvf7m30ridFpBpy.jpeg"
}, {
    "url": "http://laranov.halimtuhu.test/storage/nLkZp4vfpATEp56NStJfeAtKoHvmN2hapfxoNrEN.jpeg",
    "name": "nLkZp4vfpATEp56NStJfeAtKoHvmN2hapfxoNrEN.jpeg"
}]

Available Methods

Disk

Specify disk target for uploaded images.

ArrayImages::make('Images', 'images')
    ->disk('public'),

If not specified then the default disk will be used.

Path

Specify target path for uploaded images.

ArrayImages::make('Images', 'images)
    ->disk('public')
    ->path('images'),

If not specified then default path on selected disk will be used.

Notes

  • make sure you have specified correct APP_URL on your application
  • make sure you have specified default FILESYSTEM_DRIVER on your application

array-images's People

Contributors

alexanderwright avatar halimtuhu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

array-images's Issues

Exception occurs when namespace changed

I'm using a different namespace for my app, and this then causes the Controller not to be found:

 Symfony\Component\Debug\Exception\FatalErrorException  : Class 'App\Http\Controllers\Controller' not found

  at /Users/alexander/Code/camra/phg-laravel/vendor/halimtuhu/array-images/src/Http/Controllers/ArrayImagesController.php:8
     4| use Illuminate\Support\Facades\Storage;
     5| use App\Http\Controllers\Controller;
     6| use Illuminate\Http\Request;
     7|
  >  8| class ArrayImagesController extends Controller
     9| {
    10|     public function index(Request $request)
    11|     {
    12|         return "array images by halimtuhu";

Add custom disk and path

Can you add support methods analogs Image Field?

 ArrayImages::make('Images', 'images')
     ->disk('public')
     ->path('images')

Image urls are incorrect when using a different disk

The images are unable to preview when you use a disk different from the default one.

For instance:

ArrayImages::make('Images')->disk('s3')->path('uploads');

And your default disk is set to local. It is trying to load the image url from the local disk instead of the s3 disk.

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.