PHPackages                             yashenkov/laravel-imagetrait - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. yashenkov/laravel-imagetrait

ActivePackage[Image &amp; Media](/categories/media)

yashenkov/laravel-imagetrait
============================

ImageTrait for laravel. Upload/Delete image and thumb image, store path in DB

116[1 PRs](https://github.com/yoshkin/laravel-imagetrait/pulls)PHP

Since Oct 31Pushed 7y ago1 watchersCompare

[ Source](https://github.com/yoshkin/laravel-imagetrait)[ Packagist](https://packagist.org/packages/yashenkov/laravel-imagetrait)[ RSS](/packages/yashenkov-laravel-imagetrait/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (2)Used By (0)

Laravel ImageTrait
==================

[](#laravel-imagetrait)

> for Hacktoberfest 2017

ImageTrait for Laravel 5.4

Requirements
------------

[](#requirements)

- laravel 5.4^ (Because trait uses Storage and Image class of laravel package)

Features
--------

[](#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
-------------

[](#installing-1)

```
composer require yashenkov/laravel-imagetrait

```

Installing #2
-------------

[](#installing-2)

```
Download ImageTrait.php, than place it in app/Traits.
Replace namespase "Yashenkov\ImageTrait\Traits" by "App\Traits"

```

#### Using:

[](#using)

In your model, that have image attribute you need to add in Model use ImageTrait, for example:

```
