jaysson / eloquent_filefield by jaysson

Automatically save files assigned to eloquent model attributes
1,748
4
0
Package Data
Maintainer Username: jaysson
Maintainer Contact: prabhakarbhat@live.com (Prabhakar Bhat)
Package Create Date: 2016-03-25
Package Last Update: 2020-03-29
Language: PHP
License: MIT
Last Refreshed: 2024-11-15 15:25:33
Package Statistics
Total Downloads: 1,748
Monthly Downloads: 1
Daily Downloads: 0
Total Stars: 4
Total Watchers: 0
Total Forks: 1
Total Open Issues: 0

Eloquent File Field

Easily upload files to a directory and save the filename to database attribute.

It does not handle any image processing. Take a look at [Glide][http://glide.thephpleague.com] for that.

Install

Via Composer

$ composer require jaysson/eloquent_filefield

Usage

In your Eloquent model:

use Jaysson\EloquentFileField\FileFieldTrait;

public $fileFields = [
  'image' => [],
  'poster' => [
  	'disk' => app('config')->get('filesystems.default'),
    'path' => 'uploads/:class_slug/:attribute/:unique_id-:file_name',
    'default_path' => 'uploads/default.png'
  ]
];

Each field can have filesystem disk, path pattern and default path options. If you don't specify any of them, they will be loaded from default config.

Publish default config

$ php artisan vendor:publish 

Security

If you discover any security related issues, please email prabhakarbhat@live.com instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.