blocksystems / file-attributes
service model attributes for laravel(lumen) by files
dev-main
2021-10-19 17:58 UTC
Requires
- php: >=7.1.3
- illuminate/support: 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0 || ^7.0 || ^8.0
- league/flysystem: ^1.1
- league/flysystem-aws-s3-v3: ~1.0
Requires (Dev)
- illuminate/database: ^6.20.12 || ^7.30.4 || ^8.24.0
This package is not auto-updated.
Last update: 2024-05-01 06:19:51 UTC
README
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'