trait UploadField

Properties

protected string $directory

Upload directory.

protected null $name

File name.

protected Filesystem $storage

Storage instance.

protected bool $useUniqueName

If use unique name to store upload file.

protected bool $useSequenceName

If use sequence name to store upload file.

protected bool $retainable

Retain file when delete record from DB.

protected bool $downloadable
protected array $fileActionSettings

Configuration for setting up file actions for newly selected file thumbnails in the preview window.

protected string $storagePermission

Controls the storage permission. Could be 'private' or 'public'.

protected array $fileTypes

Methods

$this
downloadable(bool $downloadable = true)

Indicates if the underlying field is downloadable.

$this
removable()

Allow use to remove file.

$this
retainable($retainable = true)

Indicates if the underlying field is retainable.

$this
options(array $options = [])

Set options for file-upload plugin.

$this
disk(string $disk)

Set disk for storage.

$this
move(string $directory, null|string $name = null)

Specify the directory and name for upload file.

$this
dir(string $dir)

Specify the directory upload file.

$this
name(string|callable $name)

Set name of store name.

$this
uniqueName()

Use unique name for store upload file.

$this
sequenceName()

Use sequence name for store upload file.

mixed|string
getDirectory()

Get directory for store file.

void
renameIfExists(UploadedFile $file)

If name already exists, rename it.

string
objectUrl($path)

Get file visit url.

destroy()

Destroy original files.

$this
storagePermission(string $permission)

Set file permission when stored into storage.

initStorage()

Initialize the storage instance.

void
setupDefaultOptions()

Set default options form image field.

void
setupPreviewOptions()

Set preview options form image field.

array|bool
guessPreviewType($file)

No description

string
getStoreName(UploadedFile $file)

Get store name of upload file.

mixed
upload(UploadedFile $file)

Upload file and delete original file.

string
generateUniqueName(UploadedFile $file)

Generate a unique name for uploaded file.

string
generateSequenceName(UploadedFile $file)

Generate a sequence name for uploaded file.

Details

at line 101
$this downloadable(bool $downloadable = true)

Indicates if the underlying field is downloadable.

Parameters

bool $downloadable

Return Value

$this

at line 113
$this removable()

Allow use to remove file.

Return Value

$this

at line 125
$this retainable($retainable = true)

Indicates if the underlying field is retainable.

Parameters

$retainable

Return Value

$this

at line 139
$this options(array $options = [])

Set options for file-upload plugin.

Parameters

array $options

Return Value

$this

at line 155
$this disk(string $disk)

Set disk for storage.

Parameters

string $disk

Disks defined in config/filesystems.php.

Return Value

$this

Exceptions

Exception

at line 178
$this move(string $directory, null|string $name = null)

Specify the directory and name for upload file.

Parameters

string $directory
null|string $name

Return Value

$this

at line 194
$this dir(string $dir)

Specify the directory upload file.

Parameters

string $dir

Return Value

$this

at line 210
$this name(string|callable $name)

Set name of store name.

Parameters

string|callable $name

Return Value

$this

at line 224
$this uniqueName()

Use unique name for store upload file.

Return Value

$this

at line 236
$this sequenceName()

Use sequence name for store upload file.

Return Value

$this

at line 248
mixed|string getDirectory()

Get directory for store file.

Return Value

mixed|string

at line 264
void renameIfExists(UploadedFile $file)

If name already exists, rename it.

Parameters

UploadedFile $file

Return Value

void

at line 278
string objectUrl($path)

Get file visit url.

Parameters

$path

Return Value

string

at line 296
destroy()

Destroy original files.

at line 318
$this storagePermission(string $permission)

Set file permission when stored into storage.

Parameters

string $permission

Return Value

$this

at line 330
protected initStorage()

Initialize the storage instance.

at line 340
protected void setupDefaultOptions()

Set default options form image field.

Return Value

void

at line 373
protected void setupPreviewOptions()

Set preview options form image field.

Return Value

void

at line 383
protected array|bool guessPreviewType($file)

No description

Parameters

$file

Return Value

array|bool

at line 419
protected string getStoreName(UploadedFile $file)

Get store name of upload file.

Parameters

UploadedFile $file

Return Value

string

at line 447
protected mixed upload(UploadedFile $file)

Upload file and delete original file.

Parameters

UploadedFile $file

Return Value

mixed

at line 465
protected string generateUniqueName(UploadedFile $file)

Generate a unique name for uploaded file.

Parameters

UploadedFile $file

Return Value

string

at line 477
protected string generateSequenceName(UploadedFile $file)

Generate a sequence name for uploaded file.

Parameters

UploadedFile $file

Return Value

string