Giter Site home page Giter Site logo

geidelguerra / laravel-mediable Goto Github PK

View Code? Open in Web Editor NEW

This project forked from plank/laravel-mediable

0.0 1.0 0.0 1.92 MB

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

License: MIT License

PHP 100.00%

laravel-mediable's Introduction

Laravel-Mediable

Coveralls StyleCI Packagist

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

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

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

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

Read the documentation here.

License

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

About Plank

Plank is a web development agency based in Montreal, Canada.

laravel-mediable's People

Contributors

aalyusuf avatar borisdamevin avatar boumanb avatar crishoj avatar cyrulik avatar frasmage avatar geosot avatar hailwood avatar jdhmtl avatar johannesschobel avatar julesprimo avatar laravelfreelancernl avatar ls-sean-fraser avatar nadinengland avatar pet1330 avatar riesjart avatar riesjart2 avatar ryankilf avatar sebdesign avatar simonschaufi avatar timacdonald avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.