PHPackages                             leilaakbari1996/laravel-image - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. leilaakbari1996/laravel-image

ActiveLibrary[File &amp; Storage](/categories/file-storage)

leilaakbari1996/laravel-image
=============================

A reusable image management package for Laravel applications.

v1.1.0(today)00MITPHPPHP ^8.2

Since Aug 8Pushed todayCompare

[ Source](https://github.com/leilaakbari1996/laravel-image)[ Packagist](https://packagist.org/packages/leilaakbari1996/laravel-image)[ Docs](https://github.com/leilaakbari1996/laravel-image)[ RSS](/packages/leilaakbari1996-laravel-image/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (6)Versions (3)Used By (0)

Laravel Image
=============

[](#laravel-image)

A lightweight, framework-agnostic image management package for Laravel applications. Attach, validate, store, and manage images for any Eloquent model — without coupling your project to a specific implementation.

Why this package?
-----------------

[](#why-this-package)

Most Laravel projects end up rewriting the same image-upload logic for every model: validation, storage, database records, and cleanup. This package extracts that logic into a single, reusable, and testable layer built around Laravel's Service Container and SOLID principles.

Features
--------

[](#features)

- 🔌 **Polymorphic relations** — attach images to any Eloquent model without the package knowing what that model is
- 🧩 **Contract-based architecture** — swap validation or storage logic without touching the core
- ⚙️ **Configurable** — disk, path, allowed mime types, max size/dimensions, all overridable per project
- 🗑️ **Automatic file cleanup** — deleting an image record removes the physical file too (configurable)
- ✅ **Tested** — Pest test suite covering upload, validation, and deletion

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

[](#installation)

```
composer require leilaakbari1996/laravel-image
```

Publish the config file (optional):

```
php artisan vendor:publish --tag=laravel-image-config
```

Run the migrations:

```
php artisan migrate
```

Usage
-----

[](#usage)

### 1. Add the trait to any model

[](#1-add-the-trait-to-any-model)

```
use Leilaakbari1996\LaravelImage\Traits\HasImages;

class Product extends Model
{
    use HasImages;
}
```

### 2. Upload an image

[](#2-upload-an-image)

```
use Leilaakbari1996\LaravelImage\Contracts\ImageUploaderContract;

public function store(Request $request, ImageUploaderContract $uploader)
{
    $product = Product::create($request->validated());

    $image = $uploader->upload($request->file('photo'), $product);

    return response()->json(['url' => $image->url]);
}
```

### 3. Access images

[](#3-access-images)

```
$product->images;        // all images (MorphMany collection)
$product->image();       // first image (e.g. for an avatar-like use case)
$image->url;              // full public URL, disk-aware
```

### 4. Delete an image

[](#4-delete-an-image)

```
$image->delete(); // also removes the physical file from storage, if configured
```

Configuration
-------------

[](#configuration)

After publishing, `config/laravel-image.php` lets you customize:

```
return [
    'table_name' => 'laravel_image_images',
    'disk' => env('LARAVEL_IMAGE_DISK', 'public'),
    'path' => 'images',

    'validation' => [
        'allowed_mimes' => ['jpeg', 'jpg', 'png', 'webp', 'gif'],
        'max_size' => 5120,       // KB
        'max_width' => 4000,      // px
        'max_height' => 4000,     // px
    ],

    'delete_file_on_model_delete' => true,
];
```

Architecture
------------

[](#architecture)

The package is built around three contracts, so each concern can be swapped independently:

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 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 ~0 days

Total

2

Last Release

0d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/180978822?v=4)[Huszka Leila](/maintainers/leila1996)[@Leila1996](https://github.com/Leila1996)

---

Top Contributors

[![leilaakbari1996](https://avatars.githubusercontent.com/u/87874568?v=4)](https://github.com/leilaakbari1996 "leilaakbari1996 (2 commits)")

---

Tags

laravelimagestoragemediaupload

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/leilaakbari1996-laravel-image/health.svg)

```
[![Health](https://phpackages.com/badges/leilaakbari1996-laravel-image/health.svg)](https://phpackages.com/packages/leilaakbari1996-laravel-image)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[api-platform/laravel

API Platform support for Laravel

58190.1k19](/packages/api-platform-laravel)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k161.4k1](/packages/mike-bronner-laravel-model-caching)[forjedio/inertia-table

Backend-driven dynamic tables for Laravel + Inertia.js

272.0k](/packages/forjedio-inertia-table)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45844.8k1](/packages/pressbooks-pressbooks)[masterix21/laravel-licensing

Laravel licensing package with polymorphic assignment to any model, activation keys, expirations/renewals, and seat control via LicenseUsage. Supports offline verification with public-key–signed tokens, a CLI to generate/rotate/revoke keys, and an extensible architecture via config and contracts.

1614.1k4](/packages/masterix21-laravel-licensing)

PHPackages © 2026

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