PHPackages                             plank/laravel-mediable - 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. plank/laravel-mediable

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

plank/laravel-mediable
======================

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

6.4.0(2mo ago)8271.5M—3%108[3 issues](https://github.com/plank/laravel-mediable/issues)[1 PRs](https://github.com/plank/laravel-mediable/pulls)11MITPHPPHP &gt;=8.3.0CI passing

Since Jul 20Pushed 2mo ago18 watchersCompare

[ Source](https://github.com/plank/laravel-mediable)[ Packagist](https://packagist.org/packages/plank/laravel-mediable)[ RSS](/packages/plank-laravel-mediable/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (21)Versions (101)Used By (11)

Laravel-Mediable
================

[](#laravel-mediable)

[![Coveralls](https://camo.githubusercontent.com/11ddc5c633d78efcd17c6c5f9714b88ee22866161020e788edc674ac5b6dd46d/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f706c616e6b2f6c61726176656c2d6d65646961626c652e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/github/plank/laravel-mediable)[![StyleCI](https://camo.githubusercontent.com/78fca46bce0e07ba22824bb811f77008e84d44433ff40d64a7d481b6ef5dde5a/68747470733a2f2f7374796c6563692e696f2f7265706f732f36333739313131302f736869656c64)](https://styleci.io/repos/63791110)[![Packagist](https://camo.githubusercontent.com/787cdafc9ecbe4328b9978c908c75fbe02cb2cd6f9cbfd50dc8f70b28682a523/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706c616e6b2f6c61726176656c2d6d65646961626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/plank/laravel-mediable)

Laravel-Mediable is a package for easily uploading and attaching media files to models with Laravel.

Features
--------

[](#features)

- Filesystem-driven approach is easily configurable to allow any number of upload directories with different accessibility. Easily restrict uploads by MIME type, extension and/or aggregate type (e.g. `image` for JPEG, PNG or GIF).
- Many-to-many polymorphic relationships allow any number of media to be assigned to any number of other models without any need to modify their schema.
- Attach media to models with tags, in order to set and retrieve media for specific purposes, such as `'thumbnail'`, `'featured image'`, `'gallery'` or `'download'`.
- Integrated support for integration/image for manipulating image files to create variants for different use cases.

Example Usage
-------------

[](#example-usage)

Upload a file to the server, and place it in a directory on the filesystem disk named "uploads". This will create a Media record that can be used to refer to the file.

```
$media = MediaUploader::fromSource($request->file('thumb'))
	->toDestination('uploads', 'blog/thumbnails')
	->upload();
```

Attach the Media to another eloquent model with one or more tags defining their relationship.

```
$post = Post::create($this->request->input());
$post->attachMedia($media, ['thumbnail']);
```

Retrieve the media from the model by its tag(s).

```
$post->getMedia('thumbnail')->first()->getUrl();
```

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

[](#installation)

Add the package to your Laravel app using composer

```
composer require plank/laravel-mediable
```

Register the package's service provider in `config/app.php`. In Laravel versions 5.5 and beyond, this step can be skipped if package auto-discovery is enabled.

```
'providers' => [
    ...
    Plank\Mediable\MediableServiceProvider::class,
    ...
];
```

The package comes with a Facade for the image uploader, which you can optionally register as well. In Laravel versions 5.5 and beyond, this step can be skipped if package auto-discovery is enabled.

```
'aliases' => [
	...
    'MediaUploader' => Plank\Mediable\MediaUploaderFacade::class,
    ...
]
```

Publish the config file (`config/mediable.php`) of the package using artisan.

```
php artisan vendor:publish --provider="Plank\Mediable\MediableServiceProvider"
```

Run the migrations to add the required tables to your database.

```
php artisan migrate
```

Documentation
-------------

[](#documentation)

Read the documentation [here](http://laravel-mediable.readthedocs.io/en/latest/).

License
-------

[](#license)

This package is released under the MIT license (MIT).

About Plank
-----------

[](#about-plank)

[Plank](http://plankdesign.com) is a web development agency based in Montreal, Canada.

###  Health Score

75

—

ExcellentBetter than 100% of packages

Maintenance84

Actively maintained with recent releases

Popularity64

Solid adoption and visibility

Community42

Growing community involvement

Maturity94

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 74.7% 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 ~39 days

Recently: every ~111 days

Total

91

Last Release

84d ago

Major Versions

1.1.1 → 2.0.02016-09-17

2.9.0 → 3.0.02019-09-16

3.0.1 → 4.0.02019-10-11

4.4.2 → 5.0.02020-10-15

5.9.1 → 6.0.02024-04-07

PHP version history (6 changes)0.1.0PHP &gt;=5.4.0

3.0.0PHP &gt;=7.2.0

4.4.0PHP &gt;=7.3.0

5.4.0PHP &gt;=7.4.0

6.0.0PHP &gt;=8.1.0

6.4.0PHP &gt;=8.3.0

### Community

Maintainers

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

![](https://avatars.githubusercontent.com/u/108450?v=4)[Plank](/maintainers/Plank)[@plank](https://github.com/plank)

---

Top Contributors

[![frasmage](https://avatars.githubusercontent.com/u/916652?v=4)](https://github.com/frasmage "frasmage (295 commits)")[![sebdesign](https://avatars.githubusercontent.com/u/667144?v=4)](https://github.com/sebdesign "sebdesign (22 commits)")[![ls-sean-fraser](https://avatars.githubusercontent.com/u/40804044?v=4)](https://github.com/ls-sean-fraser "ls-sean-fraser (17 commits)")[![borisdamevin](https://avatars.githubusercontent.com/u/1703605?v=4)](https://github.com/borisdamevin "borisdamevin (13 commits)")[![anilkumarthakur60](https://avatars.githubusercontent.com/u/16583802?v=4)](https://github.com/anilkumarthakur60 "anilkumarthakur60 (10 commits)")[![LaravelFreelancerNL](https://avatars.githubusercontent.com/u/36150929?v=4)](https://github.com/LaravelFreelancerNL "LaravelFreelancerNL (4 commits)")[![pet1330](https://avatars.githubusercontent.com/u/4920245?v=4)](https://github.com/pet1330 "pet1330 (3 commits)")[![jdhmtl](https://avatars.githubusercontent.com/u/3738327?v=4)](https://github.com/jdhmtl "jdhmtl (3 commits)")[![selfsimilar](https://avatars.githubusercontent.com/u/784446?v=4)](https://github.com/selfsimilar "selfsimilar (2 commits)")[![GeoSot](https://avatars.githubusercontent.com/u/22406063?v=4)](https://github.com/GeoSot "GeoSot (2 commits)")[![cyrulik](https://avatars.githubusercontent.com/u/3313071?v=4)](https://github.com/cyrulik "cyrulik (2 commits)")[![Sparclex](https://avatars.githubusercontent.com/u/2805213?v=4)](https://github.com/Sparclex "Sparclex (2 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![hailwood](https://avatars.githubusercontent.com/u/709773?v=4)](https://github.com/hailwood "hailwood (2 commits)")[![syssi](https://avatars.githubusercontent.com/u/2735933?v=4)](https://github.com/syssi "syssi (1 commits)")[![abbasudo](https://avatars.githubusercontent.com/u/86796762?v=4)](https://github.com/abbasudo "abbasudo (1 commits)")[![timacdonald](https://avatars.githubusercontent.com/u/24803032?v=4)](https://github.com/timacdonald "timacdonald (1 commits)")[![ahme-d](https://avatars.githubusercontent.com/u/9767569?v=4)](https://github.com/ahme-d "ahme-d (1 commits)")[![crishoj](https://avatars.githubusercontent.com/u/20393?v=4)](https://github.com/crishoj "crishoj (1 commits)")[![EriBloo](https://avatars.githubusercontent.com/u/19932449?v=4)](https://github.com/EriBloo "EriBloo (1 commits)")

---

Tags

eloquentfile-uploadhacktoberfestlaravellaravelimageeloquentmediauploader

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/plank-laravel-mediable/health.svg)

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

###  Alternatives

[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

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

A file upload/editor intended for use with Laravel 5 to 10 and CKEditor / TinyMCE

2.2k3.3M74](/packages/unisharp-laravel-filemanager)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[watson/validating

Eloquent model validating trait.

9723.3M47](/packages/watson-validating)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[cybercog/laravel-love

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

1.2k302.7k1](/packages/cybercog-laravel-love)

PHPackages © 2026

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