Package Data | |
---|---|
Maintainer Username: | mbellido |
Maintainer Contact: | mbellido@dartika.com (Marco Bellido) |
Package Create Date: | 2017-07-19 |
Package Last Update: | 2017-10-16 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-02-06 03:07:27 |
Package Statistics | |
---|---|
Total Downloads: | 57 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Trait to upload files from inputs forms through mutator easily.
Include this in your composer.json:
{
"require": {
"dartika/laravel-uploadable-mutator": "dev-master"
}
}
and then execute:
$ composer update
In your model, add the Dartika\UploadableMutator\UploadableMutator
trait:
use Dartika\UploadableMutator\UploadableMutator;
class Post extends Model {
use UploadableMutator;
}
Now, add protected $fileFields
array with all file fields ('input' => 'upload path')
in your model:
protected $fileFields = [
'image' => 'public/images',
'pdf' => 'public/pdfs',
];
That's it!
When you save this fields, it will be uploaded automatically.
Example:
Post::create([
'title' => 'Hello world'
'image' => $request->image
]);
$this->attributes['input'] = "";
Dártika Networks SL