Cartalyst LLC.
Media by Cartalyst
2
67
0
6
2

This package requires a valid subscription. Subscribe for access.

Preface

Introduction

A Platform 4 extension to manage media.

Have a read through the Installation Guide.

Features

  • Create, update, delete files.
  • Email files.
  • Set media visibility to private/public.
  • Share file urls.
  • Download files.
  • Blade call @media('id', 'download|thumbnail')
  • Blade call @thumbnail('id', [ 'options' ], 'default')
  • Add tags.
  • Create config styles.

Examples

The $media variable used below is a reference to the MediaRepository.

$media = app('platform.media');
Retrieve all media.
$media = $media->find(1);
Dynamically create a new employee.
// $file must be an instance of `Symfony\Component\HttpFoundation\File\UploadedFile`

$media->upload($file, [
    'name'  => 'Foobar',
]);

Setup

Installation

The best and easiest way to install the Media extension is with Composer.

Preparation

Open your composer.json file and add the following to the require array:

"platform/media": "3.0.*"

Add the following lines after the require array on your composer.json file:

"repositories": [
    {
        "type": "composer",
        "url": "https://packages.cartalyst.com"
    }
]

Note: Make sure that after the required changes your composer.json file is valid by running composer validate.

Install the dependencies

Run Composer to install or update the new requirement.

php composer install

or

php composer update

Now you are able to install the extension through Platform's admin.

Usage

In this section we'll show how you can manage your media.

Repository

IoC Binding

The media repository is bound to platform.media and can be resolved out of the IoC Container using that offset.

$media = app('platform.media');

Methods

The repository contains several methods that are used throughout the extension, most common methods are listed below.

For an exhaustive list of available methods, checkout the MediaRepositoryInterface

  • find($id);

Returns an media object based on the given id.

  • findByPath($path);

Returns a collection of all media.

  • upload($file, array $input)

Uploads the given file and populates the data passed as input.

  • create(array $data);

Creates and stores a new media object.

  • update($id, array $data);

Updates an existing media object.

  • delete($id);

Deletes a media object.

You wont find fancy lifestyle graphics and marketing bravado here. Just cold... hard... code...

Code Well, Rock On!
Processing Payment...