Package Data | |
---|---|
Maintainer Username: | SergeyMiracle |
Maintainer Contact: | sergeymiracle@gmail.com (SergeyMiracle) |
Package Create Date: | 2017-01-05 |
Package Last Update: | 2023-02-06 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-27 15:03:55 |
Package Statistics | |
---|---|
Total Downloads: | 422 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 3 |
Total Watchers: | 2 |
Total Forks: | 2 |
Total Open Issues: | 0 |
A trait to automatically handle file uploads for Laravel Eloquent models.
composer require sergeymiracle/eloquent-uploadable
use SergeyMiracle\Uploadable\UploadableModelTrait;
use Illuminate\Database\Eloquent\Model;
class Post extends Model {
use UploadableModelTrait;
// define options function
public function getUploadableOptions(): array
{
return [
'attributes' => [ // model attributes which you'd like to be automatically handled by the trait.
'featured_image',
'featured_file'
],
'directory' => 'my_dir', // destination directory, optional
'disk' => 'my_disk' // flysystem disk, optional, if not present in return array disk from config file used
];
}
}
On saving array of files, a json encoded string saved in database.