Download the PHP package sahusoftcom/eloquent-image-mutator without Composer
On this page you can find all versions of the php package sahusoftcom/eloquent-image-mutator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sahusoftcom/eloquent-image-mutator
More information about sahusoftcom/eloquent-image-mutator
Files in sahusoftcom/eloquent-image-mutator
Package eloquent-image-mutator
Short Description One solution for image uploads.
License MIT
Homepage https://github.com/sahusoftcom/eloquent-image-mutator
Informations about the package eloquent-image-mutator
Eloquent Image Mutator Version: 2^
Relating an image with a model is always a pain. Eloquent Image Mutator provides an easy mutator for Eloquent models to save and retrieve images.
Storing images with Model
Upload using a form
OR
Upload using a public URL (We will download and store the image for you)
OR
Copy already present Image Object
note:-
The $user->photo_one
should be a added to
protected $image_fields
And its model should
use EloquentImageMutatorTrait;
Retrieving images with Model
You can even access the height and width
Eg (In blade file):-
Update Or Delete Images
If you update a field with a new image the old image is deleted from the system.
OR
If you delete a record from a the table the image is deleted.
Installation
Add the following line to the require
section of composer.json
:
Setup
-
In
/config/app.php
, add the following toproviders
: -
Run
php artisan vendor:publish
. -
In
/config/image.php
, you will have the default target folder.If you want to use this detination as the upload folder, Do make the directories required i.e.,
storage/app/uploads
. - In public folder you should have a soft-link pointing to the upload folder destination named
uploads
. You could do this by creating a soft link in public.Go to your projects public folder and
How to use
- The field against which you want to store the image should be of type
text
. - You should use the
EloquentImageMutatorTrait
in the Model. - Define the columns you want to inculde for image uploads.
For example:
And to then with the user object you can just use it like a property
Example:
Storing images with Model
Retrieving images with Model
Thanks!
Customization
You could customize the target folder where the images are stored. For customizing goto config/image.php
. Line no 6
and change the destination to your desired folder. Make sure the destination folder has all the permissions and the soft link in the public folder is pointing to the destionation folder.
====================================================
Eloquent Image Mutator Version: 1.*
Relating an image with a model is always a pain. Eloquent Image Mutator provides an easy mutator for Eloquent models to save and retrieve images.
Storing images with Model
Retrieving images with Model
Eg (In blade file):-
Installation
Add the following line to the require
section of composer.json
:
Setup
-
In
/config/app.php
, add the following toproviders
: -
Run
php artisan vendor:publish
. -
In
/config/image.php
, you will have the default target folder.If you want to use this detination as the upload folder, Do make the directories required i.e.,
storage/app/uploads
. - In public folder you should have a soft-link pointing to the upload folder destination named
uploads
. You could do this by creating a soft link in public.Go to your projects public folder and
How to use
- The field against which you want to store the image should be of type
text
. - You should use the
EloquentImageMutatorTrait
in the Model. - Define the columns you want to inculde for image uploads.
For example:
And to then with the user object you can just use it like a property
Example:
Storing images with Model
Retrieving images with Model
Thanks!
Customization
You could customize the target folder where the images are stored. For customizing goto config/image.php
. Line no 6
and change the destination to your desired folder. Make sure the destination folder has all the permissions and the soft link in the public folder is pointing to the destionation folder.