akbsit/nova-field-system-file

Uploading files to the server from nova.

1.0.10 2024-04-06 11:50 UTC

This package is auto-updated.

Last update: 2024-11-06 13:18:08 UTC


README

Install

To install package, you need run command:

composer require akbsit/nova-field-system-file

Next install migrations:

php artisan migrate

Connection

Package based on akbsit/laravel-system-file in repository which describes the connection to the model.

Examples

Second parameter is responsible for the collection to which the saved images or files will belong.

  1. Upload image:
public function fields(HttpRequest $oHttpRequest)
{
    return [
        Image::make(__('Image'), 'image'),
    ];
}
  1. Upload file:
public function fields(HttpRequest $oHttpRequest)
{
    return [
        File::make(__('File'), 'file'),
    ];
}
  1. Fields support validation via the method rules:
public function fields(HttpRequest $oHttpRequest)
{
    return [
        Image::make(__('Image'), 'image')
            ->rules('required', 'max:1000'),
        File::make(__('File'), 'file')
            ->rules('required', 'max:5000'),
    ];
}

Methods and properties

  • enablePartition() - enable folder generation (example: 73c/d53/dce);
  • setOriginFileName(string $sOriginFileName) - set origin file name;
  • setFileName(string $sFileName) - set file name;
  • toDir(string $sDir) - set storage folder (by default default);
  • self() - specified if the model SystemFile (by default false).