PHPackages                             levoolabs/imageable - 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. [Database &amp; ORM](/categories/database)
4. /
5. levoolabs/imageable

AbandonedArchivedLibrary[Database &amp; ORM](/categories/database)

levoolabs/imageable
===================

Eloquent Image model for uploading and displaying images with intervention/imagecache

1.1.2(7y ago)042MITPHPPHP ^7.1.3

Since Jul 19Pushed 7y agoCompare

[ Source](https://github.com/LevooLabs/imageable)[ Packagist](https://packagist.org/packages/levoolabs/imageable)[ RSS](/packages/levoolabs-imageable/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (4)Dependencies (6)Versions (5)Used By (0)

LevooLabs Imageable
===================

[](#levoolabs-imageable)

LevooLabs Imageable is an easy to use Eloquent Image model for uploading and displaying images with [intervention/imagecache](http://image.intervention.io/). The package includes Traits to add simple connection between the Image model and any other Eloquent model.

Demo
----

[](#demo)

### Get the models image in multiple size

[](#get-the-models-image-in-multiple-size)

```
$topic = Topic::where('name', 'Awsome topic')->first();
echo $topic->image->s; // Small image url
echo $topic->image->m; // Medium image url
echo $topic->image->l; // Large image url
echo $topic->image->o; // Original image url
```

### Get secondary images

[](#get-secondary-images)

```
foreach ($product->secondary_images as $image) {
    echo $image->s;
}
```

### Check whenever a model has an uploaded image

[](#check-whenever-a-model-has-an-uploaded-image)

```
if ($topic->has_image) {
    //
}
```

### Upload image to the server

[](#upload-image-to-the-server)

```
public function uploadImageAjax(Request $request, Topic $topic)
{
    if ($request->ajax()) {
        $image = $topic->store_image($request->file('file'));
        return response()->json(['ok' => $image->id], 200);
    }
    abort(404);
}
```

Or use `store_images($files, $image_type = null)` for multiple images.

### Delete image from the server

[](#delete-image-from-the-server)

```
$topic->delete_image();
```

Or use `delete_images()` to delete all the images connected to the model.

Installation
------------

[](#installation)

### Step 1: Install package

[](#step-1-install-package)

Install the package through [Composer](http://getcomposer.org/).

Run the Composer require command from the Terminal:

```
composer require levoolabs/imageable

```

### Step 2: Migrations

[](#step-2-migrations)

Run migrations with artisan command:

```
php aritsan migrate

```

This will create the following table:

```
Schema::create('images', function(Blueprint $table) {
    $table->increments('id');
    $table->integer('imageable_id')->unsigned();
    $table->string('imageable_type');
    $table->string('image_type');
    $table->string('image_path'); #NOTE relative filename with extension -> /folder/folder/filename.ext
    $table->timestamps();
});
```

### Step 3: Publish assets

[](#step-3-publish-assets)

Publish intervention config files and the Imageable default image with:

```
php artisan vendor:publish

```

### Step 4.1: Traits

[](#step-41-traits)

For the simplest use just include `SingleImageableTrait` or `MultiImageableTrait` into your Eloquent model and you are all set.

```
class Topic extends Model
{
    use \LevooLabs\Imageable\Traits\SingleImageableTrait;

    protected $table = 'topics';

    protected $fillable = [
        'title'
    ];

}
```

Or you can extend flexibility by setting these properties:

```
class Product extends Model
{
    use \LevooLabs\Imageable\Traits\MultiImageableTrait;

    public $template_base_name = "product";

    protected $image_type = MyConstants\ImageType::PRODUCT_MAIN;
    protected $secondary_image_type = MyConstants\ImageType::PRODUCT;

    protected $default_image_name = "product.jpg";

    protected $extension = "jpg";

    /* ... */
}
```

- The `$template_base_name` contains the base name for the filters defined in the imagecache config file.
- The `$image_type` and `$secondary_image_type` properties hold the value for image\_type column in the images table. The `$secondary_image_type` will only be used in `MultiImageableTrait`.
- The `$default_image_name` is the name of the placeholder image file located in `public/images/imageable` folder for models without uploaded images.

### Step 4.2: Custom filters (optional)

[](#step-42-custom-filters-optional)

If you set the `$template_base_name` value in your model you have to define the filters for that template in the `config/imagecache.php` file.

```
    'product'   => \App\ImageFilters\Product\Upload::class,
    'product-s' => \App\ImageFilters\Product\Small::class,
    'product-m' => \App\ImageFilters\Product\Medium::class,
    'product-l' => \App\ImageFilters\Product\Large::class,
```

You can read more about Intervention Image Filters [here](http://image.intervention.io/use/filters).

License
-------

[](#license)

LevooLabs Imageable is licensed under the [MIT License](http://opensource.org/licenses/MIT).

Copyright 2018 [LevooLabs](http://levoolabs.com/)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~60 days

Total

4

Last Release

2675d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a11d37583551af0786595929de53ccc1da7d9485db9e29c54334c38a01a9187d?d=identicon)[LevooLabs](/maintainers/LevooLabs)

---

Top Contributors

[![adamtrll](https://avatars.githubusercontent.com/u/10064903?v=4)](https://github.com/adamtrll "adamtrll (13 commits)")

---

Tags

laravelimageeloquentintervention

### Embed Badge

![Health badge](/badges/levoolabs-imageable/health.svg)

```
[![Health](https://phpackages.com/badges/levoolabs-imageable/health.svg)](https://phpackages.com/packages/levoolabs-imageable)
```

###  Alternatives

[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[plank/laravel-mediable

A package for easily uploading and attaching media files to models with Laravel

8271.5M11](/packages/plank-laravel-mediable)[watson/validating

Eloquent model validating trait.

9723.3M47](/packages/watson-validating)[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k302.7k1](/packages/cybercog-laravel-love)[cviebrock/eloquent-taggable

Easy ability to tag your Eloquent models in Laravel.

567694.8k3](/packages/cviebrock-eloquent-taggable)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
