MyGit

dcasia/nova-filepond

Fork: 28 Star: 49 (更新于 2024-10-29 06:44:20)

license: MIT

Language: PHP .

A Nova field for uploading File, Image and Video using Filepond.

最后发布版本: v1.0.6 ( 2024-01-31 12:52:12)

GitHub网址

Nova Filepond

Latest Version on Packagist Total Downloads License

Laravel Nova Filepond in action

A Nova field for uploading File, Image and Video using Filepond.

Installation

You can install the package via composer:

composer require digital-creative/nova-filepond

Features

  • Single/Multiple files upload
  • Sortable files
  • Preview images, videos and audio
  • Enable / Disable preview
  • Extends the original Laravel Nova File field giving you access to all the methods/functionality of the default file upload.
  • Drag and drop files
  • Paste files directly from the clipboard
  • Store custom attributes (original file name, size, etc)
  • Prunable files (Auto delete files when the model is deleted)
  • Dark mode support

Usage

The field extends the original Laravel Nova File field, so you can use all the methods available in the original field.

Basic usage:

use DigitalCreative\Filepond\Filepond;

class Post extends Resource
{
    public function fields(NovaRequest $request): array
    {
        return [
            Filepond::make('Images', 'images')
                ->rules('required')
                ->prunable()
                ->disablePreview()
                ->multiple() 
                ->limit(4),
        ];
    }
}

When uploading multiple files you will need to cast the attribute to an array in your model class

class Post extends Model {
 
    protected $casts = [
        'images' => 'array'
    ];

}

You can also store original file name / size by using storeOriginalName and storeOriginalSize methods.

use DigitalCreative\Filepond\Filepond;

class Post extends Resource
{
    public function fields(NovaRequest $request): array
    {
        return [
            Filepond::make('Images', 'images')
                ->storeOriginalName('name')
                ->storeSize('size')
                ->multiple(),
            
            // or you can manually decide how to store the data
            // Note: the store method will be called for each file uploaded and the output will be stored into a single json column
            Filepond::make('Images', 'images')
                ->multiple()
                ->store(function (NovaRequest $request, Model $model, string $attribute): array {
                    return [
                        $attribute => $request->images->store('/', 's3'),
                        'name' => $request->images->getClientOriginalName(),
                        'size' => $request->images->getSize(),
                        'metadata' => '...'
                    ];
                })
        ];
    }
}

Note when using storeOriginalName and storeSize methods, you will need to add the columns to your database table if you are in "single" file mode.

⭐️ Show Your Support

Please give a ⭐️ if this project helped you!

Other Packages You Might Like

License

The MIT License (MIT). Please see License File for more information.

最近版本更新:(数据更新于 2024-09-15 06:24:54)

2024-01-31 12:52:12 v1.0.6

2024-01-05 11:34:16 v1.0.5

2023-11-01 18:26:48 v1.0.4

2023-10-27 23:23:29 v1.0.3

2023-10-14 14:02:55 v1.0.2

2023-10-12 16:20:40 v1.0.1

2023-09-19 15:04:39 v1.0.0

2019-11-16 21:29:48 v0.2.13

2019-10-28 18:58:34 v0.2.11

2019-10-25 13:52:23 v0.2.9

主题(topics):

audio, filepond, image, laravel, laravel-nova-field, multiple, nova-4, nova-field, upload, video

dcasia/nova-filepond同语言 PHP最近更新仓库

2024-11-01 18:37:36 schmittjoh/JMSSerializerBundle

2024-10-31 21:37:53 filamentphp/filament

2024-10-28 00:16:41 symfony/var-dumper

2024-10-28 00:11:41 symfony/symfony

2024-10-11 23:44:26 coollabsio/coolify

2024-10-11 03:27:29 odan/slim4-skeleton