https://github.com/yoshkin/laravel-imagetrait
hacktoberfest 2017
https://github.com/yoshkin/laravel-imagetrait
hacktober hacktoberfest hacktoberfest2017
Last synced: 5 months ago
JSON representation
hacktoberfest 2017
- Host: GitHub
- URL: https://github.com/yoshkin/laravel-imagetrait
- Owner: yoshkin
- Created: 2017-10-31T05:47:49.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-08T02:27:56.000Z (over 7 years ago)
- Last Synced: 2024-05-02T19:47:45.895Z (about 2 years ago)
- Topics: hacktober, hacktoberfest, hacktoberfest2017
- Language: PHP
- Size: 32.2 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Laravel ImageTrait
> for Hacktoberfest 2017
ImageTrait for Laravel 5.4
## Requirements
* laravel 5.4^
(Because trait uses Storage and Image class of laravel package)
## Features
Handle image file upload and DB storage for a image file:
- on CREATE:
* stores the image file at the destination path
* generates a name
* stores the path in the DB;
- on UPDATE:
* if the value is null, deletes the image file and sets null in the DB
* if the value is different, stores the different image file and updates DB value.
## Installing #1
```
composer require yashenkov/laravel-imagetrait
```
## Installing #2
```
Download ImageTrait.php, than place it in app/Traits.
Replace namespase "Yashenkov\ImageTrait\Traits" by "App\Traits"
```
#### Using:
In your model, that have image attribute you need to
add in Model use ImageTrait, for example:
```php
uploadImageToDisk($value, $attribute_name, $this->disk, $this->destination_path, $this->imageWidth, $this->imageHeight);
}
}
```
##Licence
MIT