shridharkaushik29 / laravel-eloquent-files
File Handling with Eloquent Models in Laravel
Installs: 280
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 1
Open Issues: 0
pkg:composer/shridharkaushik29/laravel-eloquent-files
Requires
- laravel/framework: 6.0.*
README
Installation using Composer:
composer require shridharkaushik29/laravel-eloquent-files
Usage:
In your eloquent model use \Shridhar\EloquentFiles\HasFile trait and create a method for accessing file like below:
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class Member extends Model {
use \Shridhar\EloquentFiles\HasFile;
function getImageAttribute() {
return $this->file_info("image_path");
}
}
Here "image_path" is the attribute/column name on which you want to assign the path of the uploaded file, default is "file_path".
The second argument accepted by the file_info() method is the array of the following options.
| Name | Value |
|---|---|