| Package Data | |
|---|---|
| Maintainer Username: | frasmage |
| Maintainer Contact: | sean@plankdesign.com (Sean Fraser) |
| Package Create Date: | 2016-07-20 |
| Package Last Update: | 2025-03-06 |
| Home Page: | |
| Language: | PHP |
| License: | MIT |
| Last Refreshed: | 2025-10-30 03:04:29 |
| Package Statistics | |
|---|---|
| Total Downloads: | 1,376,490 |
| Monthly Downloads: | 25,725 |
| Daily Downloads: | 983 |
| Total Stars: | 811 |
| Total Watchers: | 18 |
| Total Forks: | 107 |
| Total Open Issues: | 8 |
Laravel-Mediable is a package for easily uploading and attaching media files to models with Laravel 5.
'thumbnail', 'featured image', 'gallery' or 'download'.image for jpeg, png or gif).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();
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) and migration file (database/migrations/####_##_##_######_create_mediable_tables.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
Read the documentation here.
This package is released under the MIT license (MIT).
Plank is a web development agency based in Montreal, Canada.