PHPackages                             dialloibrahima/laravel-model-media - 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. dialloibrahima/laravel-model-media

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

dialloibrahima/laravel-model-media
==================================

A lightweight trait for managing media files directly on your Eloquent models, without additional tables. Perfect when you need to attach files to models by simply storing the path as an attribute.

v3.1.0(2mo ago)11602MITPHPPHP ^8.3CI passing

Since Feb 2Pushed 2mo agoCompare

[ Source](https://github.com/ibra379/laravel-model-media)[ Packagist](https://packagist.org/packages/dialloibrahima/laravel-model-media)[ Docs](https://github.com/ibra379/laravel-model-media)[ RSS](/packages/dialloibrahima-laravel-model-media/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (26)Versions (28)Used By (0)

[![Laravel Model Media](art/banner.png)](art/banner.png)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0b0ad64a47f226331fd132521ee5cc98c6ed93dd409e3571837e9127e175ae68/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6469616c6c6f6962726168696d612f6c61726176656c2d6d6f64656c2d6d656469612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dialloibrahima/laravel-model-media)[![GitHub Tests Action Status](https://camo.githubusercontent.com/3aaeee107f9daf56b9086f79bfdfb41501631e986ec3af79189a3fbfe22d8ebb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f696272613337392f6c61726176656c2d6d6f64656c2d6d656469612f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/ibra379/laravel-model-media/actions?query=workflow%3Arun-tests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/7066b2023ffb0ae43162893486f842ae1b8dd94dfc87e7618f02755044a5f72e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6469616c6c6f6962726168696d612f6c61726176656c2d6d6f64656c2d6d656469612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dialloibrahima/laravel-model-media)[![PHP Version](https://camo.githubusercontent.com/24e633bd3deb8c04cc235d4be545b26c336741122b8c22ff480bbc80830b0572/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702de289a5253230382e332d3838393242462e7376673f7374796c653d666c61742d737175617265)](https://www.php.net/)[![Laravel Version](https://camo.githubusercontent.com/9933eeb22946b2ef8e5502689e10558f6caf5d06515612ad7e9fca2f9ba31747/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d31312e7825323025374325323031322e782d4646324432302e7376673f7374796c653d666c61742d737175617265)](https://laravel.com/)

A lightweight, zero-boilerplate media management trait for Laravel Eloquent models. Attach files directly to your existing model attributes without adding any extra database tables or complex relationships.

Tip

**Includes a built-in Glide integration** for on-the-fly image manipulation: resize, crop, convert formats, and generate responsive images.

---

Table of Contents
-----------------

[](#table-of-contents)

- [The Problem](#-the-problem)
- [The Solution](#-the-solution)
- [Comparison: Spatie vs. Model Media](#-comparison-spatie-medialibrary-vs-laravel-model-media)
- [Installation](#-installation)
- [Quick Start](#-quick-start)
- [API Reference](#-api-reference)
    - [HasMedia Trait](#hasmedia-trait)
    - [HasGlideUrls Trait](#hasglideurls-trait)
- [Advanced Usage](#-advanced-usage)
    - [Dynamic Filenames](#dynamic-filenames-via-closure)
    - [Multiple Disks](#multiple-storage-disks)
    - [Automatic Cleanup](#automatic-cleanup)
- [Image Manipulation with Glide](#-image-manipulation-with-glide)
    - [Basic Usage](#glide-basic-usage)
    - [Transformation Parameters](#transformation-parameters)
    - [Presets](#using-presets)
    - [Responsive Images](#responsive-images-srcset)
    - [Standalone Usage (Facade)](#standalone-usage-facade)
    - [Configuration](#glide-configuration)
    - [Security](#security)
    - [Cache Cleanup](#automatic-cache-cleanup)
- [How It Works](#-how-it-works)
- [Testing](#-testing)
- [Contributing](#-contributing)

---

The Problem
-----------

[](#the-problem)

Most media management packages for Laravel (like Spatie MediaLibrary) are powerful but "heavy". They often require:

- A new `media` table in your database.
- Complex Polymorphic relationships.
- Manual cleanup of files when models are deleted.
- Overkill for simple use cases where you just want to store a profile picture or a document path directly on a model.

The Solution
------------

[](#the-solution)

**Laravel Model Media** keeps it simple. It uses your **existing database columns** to store file names.

- **No Extra Tables**: Uses the columns you already have.
- **Automatic Cleanup**: Deletes old files when you re-upload or delete the model.
- **Smart Filenames**: Use model attributes or dynamic Closures for naming.
- **Zero Config**: Just add the trait and register your media.
- **Image Manipulation**: Built-in Glide integration for resizing, cropping, and format conversion.
- **Responsive Images**: Generate srcsets for `` elements automatically.

---

Comparison: Spatie MediaLibrary vs. Laravel Model Media
-------------------------------------------------------

[](#comparison-spatie-medialibrary-vs-laravel-model-media)

FeatureSpatie MediaLibraryLaravel Model Media**Philosophy**"One table for everything""Keep it on the model"**New Tables**`media` (Polymorphic)**None****Complexity**High (Conversions, Collections)**Low** (Simple &amp; Fast)**Performance**Extra Join/Query for each model**Zero extra queries****Setup**Migrations + Trait + Interface**Trait only****Image Manipulation**Built-in conversions**Glide** (included)**Ideal for**Complex CMS, Multiple galleriesProfile pics, Single documents, Simple uploads---

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

[](#installation)

```
composer require dialloibrahima/laravel-model-media
```

This installs `league/glide` automatically as a dependency, giving you image manipulation out of the box.

---

Quick Start
-----------

[](#quick-start)

### 1. Prepare your Model

[](#1-prepare-your-model)

Add the `HasMedia` trait and register which column should handle media.

```
namespace App\Models;

use DialloIbrahima\HasMedia\HasMedia;
use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    use HasMedia;

    protected static function booted()
    {
        self::registerMediaForColumn(
            column: 'profile_photo',    // Your DB column
            directory: 'avatars',       // Storage folder
            fileName: 'id',             // Name file after a model attribute (or use a Closure)
            disk: 'public'              // Optional: storage disk (default is 'public')
        );
    }
}
```

Note

The `fileName` parameter can be a model attribute name (like `'slug'`) or a `Closure` for more complex naming logic.

### 2. Handle Uploads

[](#2-handle-uploads)

Call `attachMedia()` in your controller.

```
public function update(Request $request, User $user)
{
    if ($request->hasFile('photo')) {
        // This method automatically saves the model for you!
        $user->attachMedia($request->file('photo'), 'profile_photo');
    }

    return back();
}
```

Important

`attachMedia` automatically calls `$this->save()`. You don't need to manually save the model unless you perform other modifications.

### 3. Retrieve URLs

[](#3-retrieve-urls)

```

```

### 4. Delete Media

[](#4-delete-media)

```
// Remove media and clear the column
$user->detachMedia('profile_photo');

// Media is also automatically deleted when the model is deleted
$user->delete(); // Files are cleaned up automatically
```

---

API Reference
-------------

[](#api-reference)

### HasMedia Trait

[](#hasmedia-trait)

The core trait that provides media management capabilities.

#### `registerMediaForColumn()`

[](#registermediaforcolumn)

Register a media mapping for a model column.

```
protected static function registerMediaForColumn(
    string $column,              // Database column name
    string $directory,           // Storage directory
    string|Closure $fileName,    // Attribute name or Closure for filename
    string $disk = 'public'      // Storage disk
): void
```

#### `attachMedia()`

[](#attachmedia)

Attach an uploaded file to a column.

```
public function attachMedia(UploadedFile $file, string $column): bool
```

**Returns:** `true` if storage was successful, `false` otherwise.

**Behavior:**

- Stores the file to the configured disk and directory
- Automatically deletes any previously attached file (if the filename differs)
- Updates the model attribute with the new filename
- **Automatically calls `$this->save()`** to persist the changes

#### `detachMedia()`

[](#detachmedia)

Remove media from a column and delete the file.

```
public function detachMedia(?string $column): bool
```

**Returns:** `true` when complete.

**Behavior:**

- Deletes the file from disk
- Sets the column to `null` and saves (only if the model still exists in the database)
- Passing `null` is a safe no-op that returns `true`

#### `getMediaUrl()`

[](#getmediaurl)

Get the public URL for a media file.

```
public function getMediaUrl(string $column): ?string
```

**Returns:** The full URL to the file, or `null` if no file is attached.

#### `getMediaMappings()`

[](#getmediamappings)

Get all registered media mappings for the model.

```
public function getMediaMappings(): array
```

Note

Media mappings are scoped per model class. Each model maintains its own independent set of column mappings, so you can safely use `HasMedia` on multiple models without conflicts.

---

### HasGlideUrls Trait

[](#hasglideurls-trait)

Adds Glide image manipulation capabilities. Requires the `HasMedia` trait on the same model.

Caution

This trait only works with image files. It validates MIME types and returns `null` (or throws `InvalidMediaTypeException` when `throwOnError` is `true`) for non-image files.

#### `getGlideUrl()`

[](#getglideurl)

Generate a URL for a transformed image.

```
public function getGlideUrl(
    string $column,              // Column name
    array $params = [],          // Glide transformation parameters
    bool $throwOnError = false   // Throw exception on error
): ?string
```

**Returns:** URL to the transformed image, or `null` if unavailable.

```
// Basic resize
$user->getGlideUrl('avatar', ['w' => 200, 'h' => 200]);

// Crop to square
$user->getGlideUrl('avatar', ['w' => 300, 'h' => 300, 'fit' => 'crop']);

// Convert to WebP
$user->getGlideUrl('avatar', ['w' => 400, 'fm' => 'webp', 'q' => 85]);

// With error handling
try {
    $url = $user->getGlideUrl('document', ['w' => 200], throwOnError: true);
} catch (InvalidMediaTypeException $e) {
    // Handle non-image file
}
```

#### `getGlidePresetUrl()`

[](#getglidepreseturl)

Generate a URL using a predefined preset.

```
public function getGlidePresetUrl(
    string $column,              // Column name
    string $preset,              // Preset name from config
    bool $throwOnError = false   // Throw exception on error
): ?string
```

**Returns:** URL with preset parameters applied, or `null` if the preset doesn't exist or the file is not a valid image.

```
// Use thumbnail preset (defined in config)
$user->getGlidePresetUrl('avatar', 'thumbnail');

// Use medium preset
$user->getGlidePresetUrl('cover', 'medium');
```

#### `getGlideSrcset()`

[](#getglidesrcset)

Generate a srcset attribute for responsive images.

```
public function getGlideSrcset(
    string $column,                               // Column name
    array $widths = [400, 800, 1200, 1600],       // Image widths
    bool $throwOnError = false                    // Throw exception on error
): ?string
```

```
// Default widths
$srcset = $user->getGlideSrcset('cover');
// Result: "http://...?w=400&fm=webp 400w, http://...?w=800&fm=webp 800w, ..."

// Custom widths for mobile-first
$srcset = $user->getGlideSrcset('hero', [375, 768, 1024, 1920]);
```

**Usage in Blade:**

```

```

#### `hasImageMedia()`

[](#hasimagemedia)

Check if a column contains a valid image file.

```
public function hasImageMedia(string $column): bool
```

```
@if($user->hasImageMedia('avatar'))

@else

@endif
```

---

Advanced Usage
--------------

[](#advanced-usage)

### Dynamic Filenames via Closure

[](#dynamic-filenames-via-closure)

If you need complex naming logic, use a Closure:

```
use Illuminate\Support\Str;

self::registerMediaForColumn(
    column: 'invoice_pdf',
    directory: 'invoices',
    fileName: fn ($model, $file) => "invoice-{$model->number}-" . Str::random(5)
);
// Result: invoice-INV-001-x7kP2.pdf
```

The Closure receives:

- `$model` - The Eloquent model instance
- `$file` - The `UploadedFile` instance

### Multiple Storage Disks

[](#multiple-storage-disks)

```
// Store avatars on public disk
self::registerMediaForColumn(
    column: 'avatar',
    directory: 'avatars',
    fileName: 'id',
    disk: 'public'
);

// Store private documents on S3
self::registerMediaForColumn(
    column: 'contract',
    directory: 'contracts',
    fileName: fn ($model) => "contract-{$model->id}",
    disk: 's3'
);
```

### Automatic Cleanup

[](#automatic-cleanup)

You don't need to do anything! Laravel Model Media automatically:

- **Deletes the old file** when you re-upload a new one to the same column (only if the filename differs).
- **Deletes all associated files** when the model is deleted (via Model Observer).

---

Image Manipulation with Glide
-----------------------------

[](#image-manipulation-with-glide)

The package includes a built-in [Glide](https://glide.thephpleague.com/) integration for on-the-fly image manipulation.

Add the `HasGlideUrls` trait to your model alongside `HasMedia`:

```
use DialloIbrahima\HasMedia\HasMedia;
use DialloIbrahima\HasMedia\Plugins\Glide\HasGlideUrls;

class User extends Model
{
    use HasMedia, HasGlideUrls;

    // ...
}
```

Publish the Glide configuration:

```
php artisan vendor:publish --tag=model-media-glide-config
```

### Glide Basic Usage

[](#glide-basic-usage)

Once configured, the `HasGlideUrls` trait provides convenient methods to generate URLs directly from your models:

```
// Resize to 200x200
$url = $user->getGlideUrl('avatar', ['w' => 200, 'h' => 200]);

// Crop to fit
$url = $user->getGlideUrl('avatar', ['w' => 300, 'h' => 300, 'fit' => 'crop']);

// Use a preset defined in config
$url = $user->getGlidePresetUrl('avatar', 'thumbnail');

// Get a responsive srcset
$srcset = $user->getGlideSrcset('avatar');
```

### Transformation Parameters

[](#transformation-parameters)

ParameterDescriptionExample`w`Width in pixels`['w' => 200]``h`Height in pixels`['h' => 200]``fit`Fit mode: `contain`, `max`, `fill`, `stretch`, `crop``['fit' => 'crop']``fm`Format: `jpg`, `png`, `gif`, `webp``['fm' => 'webp']``q`Quality (0-100)`['q' => 85]``blur`Blur (0-100)`['blur' => 5]``bri`Brightness (-100 to 100)`['bri' => 10]``con`Contrast (-100 to 100)`['con' => 10]``gam`Gamma (0.1 to 9.99)`['gam' => 1.5]``sharp`Sharpen (0-100)`['sharp' => 10]``flip`Flip: `v` (vertical), `h` (horizontal), `both``['flip' => 'h']``or`Orientation: `auto`, `0`, `90`, `180`, `270``['or' => 'auto']``border`Border in format `width,color,method``['border' => '5,FFFFFF,overlay']`See the [Glide documentation](https://glide.thephpleague.com/) for all available parameters.

### Using Presets

[](#using-presets)

Presets allow you to define reusable transformation sets:

```
// config/model-media-glide.php
'presets' => [
    'thumbnail' => [
        'w' => 200,
        'h' => 200,
        'fit' => 'crop',
        'fm' => 'webp',
        'q' => 90,
        'or' => 'auto',
    ],
    'medium' => [
        'w' => 800,
        'h' => 600,
        'fit' => 'contain',
        'fm' => 'webp',
        'q' => 85,
        'or' => 'auto',
    ],
    'og-image' => [
        'w' => 1200,
        'h' => 630,
        'fit' => 'crop',
        'fm' => 'jpg',  // Facebook/LinkedIn don't support webp
        'q' => 85,
        'or' => 'auto',
    ],
],
```

Then use them in your code:

```
$thumbnailUrl = $user->getGlidePresetUrl('avatar', 'thumbnail');
$ogImageUrl = $post->getGlidePresetUrl('cover', 'og-image');
```

Note

`getGlidePresetUrl()` returns `null` if the preset name doesn't exist in the configuration.

### Responsive Images (srcset)

[](#responsive-images-srcset)

Generate responsive image sets automatically:

```

```

### Standalone Usage (Facade)

[](#standalone-usage-facade)

You can generate Glide URLs anywhere (controllers, services, Blade) using the `Glide` facade, even without an Eloquent model:

```
use DialloIbrahima\HasMedia\Plugins\Glide\Facades\Glide;

// Generate a URL for a specific path
$url = Glide::url('avatars/user-1.jpg', ['w' => 200, 'fit' => 'crop']);

// Use a preset
$url = Glide::preset('posts/cover.png', 'medium');

// Generate a responsive srcset
$srcset = Glide::srcset('products/hero.webp', [400, 800, 1200]);

// Clear cache for a specific file
Glide::deleteCache('avatars/user-1.jpg');
```

Note

`Glide::url()` automatically validates that the file exists and is a valid image before generating the URL. If validation fails, it returns `null`. `Glide::preset()` also returns `null` if the preset name doesn't exist.

### Glide Configuration

[](#glide-configuration)

Publish the configuration file:

```
php artisan vendor:publish --tag=model-media-glide-config
```

```
// config/model-media-glide.php
return [
    // Routes
    'routes_enabled' => true,
    'route_prefix' => 'media',
    'middleware' => ['web'],

    // Security (URL Signing)
    'secure' => env('GLIDE_SECURE', false),
    'signature_key' => env('GLIDE_SIGNATURE_KEY', ''),

    // Storage Disks (supports S3, R2, and any Flysystem driver)
    'source_disk' => env('GLIDE_SOURCE_DISK', 'public'),
    'source_path_prefix' => env('GLIDE_SOURCE_PATH_PREFIX', ''),

    'cache_disk' => env('GLIDE_CACHE_DISK', 'local'),
    'cache_path' => env('GLIDE_CACHE_PATH', 'glide-cache'),

    'watermarks_disk' => env('GLIDE_WATERMARKS_DISK', 'local'),
    'watermarks_path' => env('GLIDE_WATERMARKS_PATH', 'watermarks'),

    // Server
    'driver' => env('GLIDE_DRIVER', 'imagick'), // 'imagick' recommended over 'gd'
    'max_image_size' => env('GLIDE_MAX_IMAGE_SIZE', 4000 * 4000), // 16MP

    // Presets (reusable transformation sets)
    'presets' => [
        'avatar' => ['w' => 110, 'h' => 110, 'fit' => 'crop', 'fm' => 'webp', 'q' => 90, 'or' => 'auto'],
        'thumbnail' => ['w' => 200, 'h' => 200, 'fit' => 'crop', 'fm' => 'webp', 'q' => 90, 'or' => 'auto'],
        // ...
    ],
];
```

Tip

The package uses **Laravel disk names** instead of hardcoded paths. This means it works seamlessly with S3, Cloudflare R2, or any Flysystem driver. Just set `GLIDE_SOURCE_DISK=s3` in your `.env` file.

Important

`imagick` is strongly recommended over `gd` as the image driver. Imagick uses Lanczos resampling which produces sharper, cleaner results compared to gd's bilinear interpolation. Verify it's installed with `php -m | grep imagick`.

### Optimization Support

[](#optimization-support)

The package is fully compatible with Laravel's optimization system:

```
php artisan optimize
```

This will cache your configuration and routes while maintaining full functionality, including secure image signatures.

### Security

[](#security)

Enable URL signing to prevent unauthorized image manipulation (DoS protection):

```
GLIDE_SECURE=true
GLIDE_SIGNATURE_KEY=your-32-character-random-string
```

Generate a secure key:

```
php artisan tinker
>>> Str::random(32)
```

When secure mode is enabled, all Glide URLs will be cryptographically signed. Requests with invalid or missing signatures receive a `403` response.

### Automatic Cache Cleanup

[](#automatic-cache-cleanup)

The `HasGlideUrls` trait automatically registers a `GlideCacheObserver` that cleans up cached images when:

- **Image is updated**: When you attach a new image to a column, the old cached versions are deleted
- **Model is deleted**: All cached images for the model are removed

This happens automatically - you don't need to configure anything. The observer:

1. Detects when a media column changes
2. Finds cached transformations for the old image
3. Deletes them from the Glide cache directory

This prevents stale cached images from being served and saves disk space.

**Manual Cache Clearing**

If you need to manually clear the cache for a specific image:

```
use DialloIbrahima\HasMedia\Plugins\Glide\Facades\Glide;

Glide::deleteCache('avatars/user-1.jpg');
```

---

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

[](#configuration)

You can publish the configuration files to customize the package behavior:

```
# Publish all configurations
php artisan vendor:publish --provider="DialloIbrahima\HasMedia\LaravelModelMediaServiceProvider"

# Or use specific tags
php artisan vendor:publish --tag=laravel-model-media-config
php artisan vendor:publish --tag=model-media-glide-config
```

- `laravel-model-media-config`: General settings.
- `model-media-glide-config`: Glide-specific settings (storage disks, presets, security, image driver).

---

How It Works
------------

[](#how-it-works)

 ```
graph TD
    subgraph Upload ["1. ATTACH (Upload)"]
        A[File Uploaded] --> B[attachMedia Method]
        B --> C[Retrieve Mapping]
        C --> D[Generate Filename]
        D --> E[Store to Disk]
        E --> F[Update Model Attribute]
    end

    subgraph Update ["2. UPDATE (Auto-Cleanup)"]
        G[Replace File] --> H[Identify Old File]
        H --> I[Delete Old File from Disk]
        I --> J[Proceed with New Upload]
    end

    subgraph Delete ["3. DELETE (Full Cleanup)"]
        K[Model Deleted] --> L[MediaObserver Triggers]
        L --> M[Fetch All Mappings]
        M --> N[Delete All Files from Disk]
    end

    subgraph Glide ["4. GLIDE (Image Transform)"]
        O[getGlideUrl Called] --> P[Validate Image Type]
        P --> Q[Build Transform URL]
        Q --> R[Glide Server Processes]
        R --> S[Return Cached/Generated Image]
    end

    F -.-> G
    J --> B
    F -.-> O
```

      Loading ---

Testing
-------

[](#testing)

The package includes a robust test suite. You can run it via composer:

```
composer test
```

We test for:

- Correct storage path and filename generation
- Automatic deletion of old media on update
- Garbage collection of files on model deletion
- Glide URL generation and transformation
- Glide preset and srcset generation
- Image type validation (only images allowed for Glide)
- Error handling for non-image files (`InvalidMediaTypeException`)
- Glide response factory (streaming, caching headers, 304 Not Modified)
- Signature validation for secure URLs

---

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Credits
-------

[](#credits)

- [Ibrahima Diallo](https://github.com/ibra379)
- [All Contributors](../../contributors)

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance88

Actively maintained with recent releases

Popularity20

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

Total

17

Last Release

61d ago

Major Versions

v1.0.0 → v2.0.02026-02-06

v2.2.2 → v3.0.02026-02-21

PHP version history (2 changes)v1.0.0PHP ^8.4

v2.0.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/7cafc8af87d07b3a6ba9d7056a5f21f3dac5ef395705b3893ee24d1416bb302c?d=identicon)[ibra379](/maintainers/ibra379)

---

Top Contributors

[![ibra379](https://avatars.githubusercontent.com/u/102914230?v=4)](https://github.com/ibra379 "ibra379 (74 commits)")

---

Tags

laravelmodeleloquentstorageimagesmediauploadglidefile management

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/dialloibrahima-laravel-model-media/health.svg)

```
[![Health](https://phpackages.com/badges/dialloibrahima-laravel-model-media/health.svg)](https://phpackages.com/packages/dialloibrahima-laravel-model-media)
```

###  Alternatives

[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[lacodix/laravel-model-filter

A Laravel package to filter, search and sort models with ease while fetching from database.

17649.9k](/packages/lacodix-laravel-model-filter)[rennokki/befriended

Eloquent Befriended brings social media-like features like following, blocking and filtering content based on following or blocked models.

76292.2k1](/packages/rennokki-befriended)[mostafaznv/larupload

Larupload is a ORM based file uploader for laravel to upload image, video, audio and other known files.

73403.7k3](/packages/mostafaznv-larupload)[elipzis/laravel-cacheable-model

Automatic query-based model cache for your Laravel app

15546.1k](/packages/elipzis-laravel-cacheable-model)[visual-ideas/moonshine-spatie-medialibrary

Spatie\\MediaLibrary field for MoonShine Laravel admin panel

2014.1k](/packages/visual-ideas-moonshine-spatie-medialibrary)

PHPackages © 2026

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