Download the PHP package oza/user-images-manager without Composer
On this page you can find all versions of the php package oza/user-images-manager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download oza/user-images-manager
More information about oza/user-images-manager
Files in oza/user-images-manager
Package user-images-manager
Short Description A package to help you manage your users images such as avatars or covers
License MIT
Homepage https://github.com/oza75/UserImagesManager
Informations about the package user-images-manager
Laravel Package that help your to manage your users images such as avatars and covers
-
Requirements
- PHP 7.0 or higher
- Laravel 5.6.x or higher
-
Installation
Just run a :
- With Laravel 5.6.x, thanks to Laravel discovering system the ServiceProvider is automatically added to your Providers
-
Architecture
The data is represented in an array containing two fields. A "current" field that contains the currently used image and another "other" field that contains all the images that have been used.
Eg:
-
How to Use
-
Just Add the
UsersImagesManager
trait to your Profile Model. -
In your config folder, Open
Profile.php
and config your Profile table and options: -
After theses steps, you can call
AvatarManager or CoverManager etc...
.- :bangbang: :warning: :boom: The Profile Model must be a user's profile not only The Model Class, that means it must have a user_id fields etc...
Eg:
-
Available Manager
-
Avatar Manager
Return an Instance of Avatar Class
-
Cover Manager
Return an Instance of Cover Class
-
-
Available Methods for each Manager
-
Current
Return a current image for a Manager
-
Current In Array format
Return an array for current image
Output:
-
All
Return All images for a Manager
-
Get By Id
Return an image with a specific id
-
Get By source
Return a collection of all images that have a specific source
-
Others
Return all images that have been used before for a Manager
-
Set
Put an image to database: it take the image link (string)
-
Set by Id
Put an image that has already been used as an avatar, cover, etc. This can be useful if for example when the user wants to change his avatar he is shown all the images that had chosen it before and he has the choice to put an old image or a new image
-
Set A Random Image
You can use it to set a default Image when user is registered.
-
Change or Update
Changes the value of the collection whose id is passed in the parameters by the remplacement value passed. It takes a third parameter which is the field of interest. if no value is specified then if the replacement value is an array, the entire collection will be replaced, else if the replacement value is a string, only the src attribute will be changed otherwise if it is not a string , nor an array, an exception will be thrown
-
All Methods are in MethodsInterface
-
-
-
Add a Custom Manager
Just create a class that extends to Manager Class and implements MethodsInterface
Then add it to UserImagesManager trait or create a new Trait and use it inside your profile model
-