An open API service indexing awesome lists of open source software.

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

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