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

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

sertxudeveloper/laravel-media-model
===================================

Attach media files to your models

v1.3.0(2y ago)113.1k[1 PRs](https://github.com/sertxudeveloper/laravel-media-model/pulls)MITPHPPHP ^8.1|^8.2

Since Jun 2Pushed 1y ago1 watchersCompare

[ Source](https://github.com/sertxudeveloper/laravel-media-model)[ Packagist](https://packagist.org/packages/sertxudeveloper/laravel-media-model)[ Docs](https://github.com/sertxudeveloper/laravel-media-model)[ Fund](https://buymeacoffee.com/sertxudeveloper)[ GitHub Sponsors](https://github.com/sertxudev)[ RSS](/packages/sertxudeveloper-laravel-media-model/feed)WikiDiscussions main Synced 1mo ago

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

[![Laravel Media Model by Sertxu Developer](/art/socialcard.png)](/art/socialcard.png)

Attach media files to your models
=================================

[](#attach-media-files-to-your-models)

[![](https://camo.githubusercontent.com/8664a3cae85a10767a873991fdc5a60a827c4f7fe8a43f6ab49a902590938240/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f736572747875646576656c6f7065722f6c61726176656c2d6d656469612d6d6f64656c)](https://camo.githubusercontent.com/8664a3cae85a10767a873991fdc5a60a827c4f7fe8a43f6ab49a902590938240/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f736572747875646576656c6f7065722f6c61726176656c2d6d656469612d6d6f64656c) [![](https://github.com/sertxudeveloper/laravel-media-model/actions/workflows/run-tests.yml/badge.svg)](https://github.com/sertxudeveloper/laravel-media-model/actions/workflows/run-tests.yml/badge.svg) [![](https://camo.githubusercontent.com/298dded994af18fa7f35a229188329565c5332fa90e7be24db40381d74f589f5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f736572747875646576656c6f7065722f6c61726176656c2d6d656469612d6d6f64656c)](https://camo.githubusercontent.com/298dded994af18fa7f35a229188329565c5332fa90e7be24db40381d74f589f5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f736572747875646576656c6f7065722f6c61726176656c2d6d656469612d6d6f64656c) [![](https://camo.githubusercontent.com/b6f5906751880149003f9200660f92d6f1ca75afab4e8849009f24bd14470b02/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f736572747875646576656c6f7065722f6c61726176656c2d6d656469612d6d6f64656c)](https://camo.githubusercontent.com/b6f5906751880149003f9200660f92d6f1ca75afab4e8849009f24bd14470b02/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f736572747875646576656c6f7065722f6c61726176656c2d6d656469612d6d6f64656c) [![](https://camo.githubusercontent.com/96610878bdf7e9507fafe4f44529b84988d0c21a69dceca337c6705acf2eab69/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736572747875646576656c6f7065722f6c61726176656c2d6d656469612d6d6f64656c)](https://camo.githubusercontent.com/96610878bdf7e9507fafe4f44529b84988d0c21a69dceca337c6705acf2eab69/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736572747875646576656c6f7065722f6c61726176656c2d6d656469612d6d6f64656c) [![](https://camo.githubusercontent.com/aaea3545f165afd3d74a7195ad764186a3a06a1becde3959b6d7f2d7ba8cf43f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f736572747875646576656c6f7065722f6c61726176656c2d6d656469612d6d6f64656c)](https://camo.githubusercontent.com/aaea3545f165afd3d74a7195ad764186a3a06a1becde3959b6d7f2d7ba8cf43f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f736572747875646576656c6f7065722f6c61726176656c2d6d656469612d6d6f64656c) [![](https://camo.githubusercontent.com/7c8a44f328f230124d0e4b61a24b545dce9499662b3dfac1d12a7c085a0b5474/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f736572747875646576656c6f7065722f6c61726176656c2d6d656469612d6d6f64656c)](https://camo.githubusercontent.com/7c8a44f328f230124d0e4b61a24b545dce9499662b3dfac1d12a7c085a0b5474/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f736572747875646576656c6f7065722f6c61726176656c2d6d656469612d6d6f64656c) [![Codecov Test coverage](https://camo.githubusercontent.com/37eb4fc3aed9e2d14621c06250777efead8037d4208cdaa191f3e1489e7262ad/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f736572747875646576656c6f7065722f6c61726176656c2d6d656469612d6d6f64656c)](https://app.codecov.io/gh/sertxudeveloper/laravel-media-model)

When developing an app, you may want to attach media files to your models, such as images, videos, or documents. With this package, you can easily attach media files to your models.

The media files are stored in the specified disk and are related to the model using your database.

You can link local media files or remote ones without needing to download them to your server.

The main difference between this package and the other ones available is that this package allows you to relate media files to your models using a custom table per model.

Allowing you to manage the media tables per model instead of one unique media table for all models.

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

[](#installation)

You can install the package via composer:

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

Next, you should publish the config file and the migrations:

```
php artisan vendor:publish --provider "SertxuDeveloper\Media\MediaServiceProvider"
```

After that, you can run the new migrations:

```
php artisan migrate
```

Finally, you can start using the package!

Usage
-----

[](#usage)

You should modify the model that you want to attach media files to.

```
