Download the PHP package ssntpl/laravel-files without Composer
On this page you can find all versions of the php package ssntpl/laravel-files. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ssntpl/laravel-files
More information about ssntpl/laravel-files
Files in ssntpl/laravel-files
Package laravel-files
Short Description Associate files with Eloquent models
License MIT
Homepage https://github.com/ssntpl/laravel-files
Informations about the package laravel-files
Associate files with Eloquent models
This is a simple package to associate files with your eloquent model in laravel.
Installation
You can install the package via composer:
Run the migrations with:
Optionally, You can publish and run the migrations with:
You can publish the config file with:
This is the contents of the published config file:
Usage
Add the HasFiles
trait to your model.
Add new file to the model.
Defining the FilePrefix for the model.
Defining FilePrefix dynamically. Sometimes we don't need a fixed path to store all the files of the model. You can use the FilePrefix attribute to create dynamic file prefix.
Accessing the File model.
Fetch single file. An excpeption is thrown if none, or more than one file is available.
Fetch multiple file relation.
Testing
TODO
- [ ] Declare the
Ssntpl\LaravelFiles\Contracts\File
contract - [ ] Add option to define default disk for every model
- [ ] Add path() method that returns the full path of the file
- [ ] Make File model sub-class of
Illuminate\Http\File
and see if all the methods work fine. - [ ] See if destroy/delete method can be modified in trait to handle the file objects
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Sam
- All Contributors
License
The MIT License (MIT). Please see License File for more information.