mikebronner / nova-file-upload-field

The easiest drag-and-drop file uploading field for Laravel Nova.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add documentation, video, screenshots, etc.

mikebronner opened this issue · comments

Would love to try this package. Would be great to know how to install and get it set up.

Sorry about the lack of documentation. Will work on that. In the mean while:

  1. composer require genealabs\nova-file-upload-field.
  2. Add it as a field in your Nova resource:
<?php namespace App\Nova;

use GeneaLabs\NovaFileUploadField\FileUpload;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\Textarea;

class Image extends Resource
{
    public static $model = 'App\Image';
    public static $title = 'title';
    public static $search = [
        "id",
        "description",
        "title",
    ];

    public function fields(Request $request)
    {
        return [
            ID::make()
                ->sortable(),
            Text::make("Title", "title")
                ->sortable()
                ->rules("required", "max:255"),
            FileUpload::make("Image", "path")
                ->thumbnail(function ($image) {
                    return $image
                        ? asset($image)
                        : '';
                })
                ->disk("tenant")
                ->path("media")
                ->prunable(),
            Textarea::make("Description"),
        ];
    }
}

Sweet, thank you @mikebronner!

@kirschbaum NP :) please let me know if you encounter any issues, or have ideas for improvements. :)

typo in

composer require genealabs\nova-file-upload-field

this worked

composer require generalabs/nova-file-upload-field