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

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

bakkali/laravel-media
=====================

Simple polymorphic media library for Laravel

v1.1.0(10mo ago)2131MITPHPPHP ^8.1

Since Jun 28Pushed 4mo agoCompare

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

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

📦 Laravel Media
===============

[](#-laravel-media)

[![Latest Version on Packagist](https://camo.githubusercontent.com/2ef07cb5e07564c80c40a5830e32a9b8cefb040e0fa1cddd766870b37a64a360/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62616b6b616c692f6c61726176656c2d6d656469612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bakkali/laravel-media)[![Total Downloads](https://camo.githubusercontent.com/9fd5e5e849ef431d2be285f446f9e474b37e963b6b6c780d9b642655e5c5347a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f62616b6b616c692f6c61726176656c2d6d656469612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bakkali/laravel-media)[![License](https://camo.githubusercontent.com/cc6f25e786301866b4faa1e5ba664fcb457558c81d61f4c4a80e55717afe2524/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f62616b6b616c692f6c61726176656c2d6d656469612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bakkali/laravel-media)

Simple, lightweight **polymorphic media library** for Laravel.
Attach, retrieve, and manage media files (images, documents, etc.) on any Eloquent model.

> 🛠 Created by [Yusuf Bakkali](https://github.com/yusufbakkali12)

✨ Features
----------

[](#-features)

- Polymorphic relation: attach media to any Eloquent model
- Custom collection names (e.g., 'gallery', 'cover')
- JSON fields for flexible metadata
- Easily add / get / remove media files
- Designed to be simple &amp; extendable

---

⚡ Installation
--------------

[](#-installation)

### 1️⃣ Require the package

[](#1️⃣-require-the-package)

```
 composer require bakkali/laravel-media:dev-main
```

### 2️⃣ Publish migration &amp; migrate

[](#2️⃣-publish-migration--migrate)

```
 php artisan vendor:publish --tag=media-migrations
 php artisan migrate
```

🧩 Usage
=======

[](#-usage)

```
use Bakkali\Media\Traits\HasMedia;

class Post extends Model
{
    use HasMedia;

    // your code...
}
```

📥 Add media to a model
----------------------

[](#-add-media-to-a-model)

```
$post = Post::find(1);

// Add a media file to 'images' collection
$post->addMedia('/path/to/file.jpg', 'images');
```

📂 Get media by collection
-------------------------

[](#-get-media-by-collection)

```
$images = $post->getMedia('images');

foreach ($images as $media) {
    echo $media->file_name;
    echo $media->disk;
}
```

✏ Update media attributes
-------------------------

[](#-update-media-attributes)

```
$post->updateMedia($mediaId, [
    'name' => 'New name'
]);
```

🧹 Soft delete media (alias)
---------------------------

[](#-soft-delete-media-alias)

```
$post->destroyMedia($mediaId);
```

❌ Permanently delete media
--------------------------

[](#-permanently-delete-media)

```
$post->forceDeleteMedia($mediaId);
```

🛠 Development &amp; Updates
===========================

[](#-development--updates)

```
- composer update bakkali/laravel-media:dev-main
```

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance67

Regular maintenance activity

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.4% 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

319d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/79841fe7f01f442665ba0faa095d5b6c18064f0e40f2baf403b275945f5f0197?d=identicon)[bakkali](/maintainers/bakkali)

---

Top Contributors

[![yusufbakkali12](https://avatars.githubusercontent.com/u/109297950?v=4)](https://github.com/yusufbakkali12 "yusufbakkali12 (17 commits)")[![bakkaliuhc](https://avatars.githubusercontent.com/u/218114170?v=4)](https://github.com/bakkaliuhc "bakkaliuhc (1 commits)")

### Embed Badge

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

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

###  Alternatives

[aws/aws-sdk-php-laravel

A simple Laravel 9/10/11/12/13 service provider for including the AWS SDK for PHP.

1.7k35.6M75](/packages/aws-aws-sdk-php-laravel)[illuminate/filesystem

The Illuminate Filesystem package.

15261.6M2.6k](/packages/illuminate-filesystem)[stechstudio/laravel-zipstream

A fast and simple streaming zip file downloader for Laravel.

4633.7M3](/packages/stechstudio-laravel-zipstream)[spatie/laravel-google-cloud-storage

Google Cloud Storage filesystem driver for Laravel

2408.9M13](/packages/spatie-laravel-google-cloud-storage)[azure-oss/storage-blob-laravel

Azure Storage Blob filesystem driver for Laravel

63582.2k1](/packages/azure-oss-storage-blob-laravel)[spatie/laravel-backup-server

Backup multiple applications

17016.7k1](/packages/spatie-laravel-backup-server)

PHPackages © 2026

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