pinpon/laravel-medialibrary-uploader

Simple helper to directly upload file to your model's media collections


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

An easy-to-use helper to directly upload files from request to your models' media collections

use Pinpon\Uploader\MediaUploader

MediaUploader::upload(['image'])->to($model);

Installation

You can install the package via composer:

composer require pinpon/laravel-medialibrary-uploader

Usage

Warning: The request file key must match the media collection's name

use Pinpon\Uploader\MediaUploader

$model = Model::first();

// Upload from one key
MediaUploader::upload('image')->to($model);

// Upload from multiple keys
MediaUploader::upload(['image', 'banner'])->to($model);


$model->getMedia('image');
$model->getMedia('banner');

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.