Download the PHP package kingofcode/laravel-uploadable without Composer
On this page you can find all versions of the php package kingofcode/laravel-uploadable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kingofcode/laravel-uploadable
More information about kingofcode/laravel-uploadable
Files in kingofcode/laravel-uploadable
Package laravel-uploadable
Short Description Laravel Uploadable trait to automatically upload images and files with minimum configuration
License MIT
Informations about the package laravel-uploadable
Laravel-Uploadable
Laravel Uploadable trait to automatically upload images and files with minimum configuration.
Introduction
This package can help you to easily make uploads, using only one field in the database, and some simple attributes in your model class. With the default configuration, the package makes thumb, medium and normal image uploads. It can be used for other files upload too, like PDF, etc.
Installation
This package includes Intervention Image to resize and manage the images.
For Laravel version less than 5.8.10, please use 0.1.7 version, as 0.1.8 added model replication that is supported only for Laravel > 5.8.10
About Upload
This package uses the Laravel File Storage to keep the file management. The files will be stored inside the default disk. For example, if you are using the public disk, to access the images or files, you need to create a symbolic link inside your project:
And then, configure your default filesystem, inside config/filesystems.php to point the public disk:
Usage
To use this package, import the Uploadable trait in your model:
And then, configure your uploadable fields for images and files inside your model.
That's all! After this configuration, you can send file data from the client side with the same name of each file field of the model. The package will make the magic!
Change Image Upload Size
The default sizes (width) for images are:
- thumb - 100px
- medium - 300px
- normal - Image width
You can modify these values directly in the $uploadableImages array. The accepted values are: image_width or a number specifying the quantity of pixels.
Change Image Upload Types
By default, this package saves thumb, medium and normal images. To disable some upload type, add this array to your model:
Setting the upload folder name
The upload will be made inside a specific folder with the name of the model, but in the plural mode. Eg: for the Product model, the images will be uploaded to the 'images/products' directory, and the other files, inside 'files/products'. If you want to modify this directory, add this code to your model:
Getting the File Path inside Views, etc
To get an image file path, you can call getImagePath($imageField, $type) from your object. Eg:
And to get a simple file path, call getFilePath($fileField):
Inspiration
The basic structure of this package is inspired in the Laravel Auto Upload package
Contributing
Feel free to comment, open issues and send PR's. Enjoy it!!
License
MIT