blocksystems/file-attributes

service model attributes for laravel(lumen) by files

Installs: 3

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/blocksystems/file-attributes

dev-main 2021-10-19 17:58 UTC

This package is not auto-updated.

Last update: 2026-01-07 14:32:38 UTC


README

Version License

Document

file attributes for laravel(lumen)

this composer auto upload files and delete before files

[in your model class]

protect $fileable = ['thumbnail', 'profile'];

e.g (when model creating)

User::create(['thumbnail' => $request->file('thumbnail'), 'profile' => $request->file('profile')]);
$user->thumbnail; // will be 's3 or local path'

e.g (multiple files ※but if you want that, please cast your attribute to json like "php protected $casts = ['attirbute' => 'json']")

User::create(['thumbnail' => [$request->file('thumbnail'), $request->file('profile')]]);

##Set prefix file path

protect $filablePrefix = 'admin'; // including slash or not, everything is OK.

##Set file path

protect $filablePath = 'admin/files'; // including slash or not, everything is OK.

##Set turn off automatically deleting file when attributes changed or deleted

protect $fileAutoDeleting = false;  // default : true

##Everytime when attribute get changed value, will change dynamically file to url string

protect $fileableSync = true; // default : false

e.g

$user->thumbnail = $request->file('thumbnail');
// (without saving) will be 's3 or local path'