PHP code example of devfactory / media

1. Go to this page and download the library: Download devfactory/media library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

devfactory / media example snippets


'Devfactory\Media\MediaServiceProvider',
'That0n3guy\Transliteration\TransliterationServiceProvider',

'Devfactory\Media\MediaServiceProvider',
'That0n3guy\Transliteration\TransliterationServiceProvider',



class User extends Eloquent {

  use \Devfactory\Media\MediaTrait;

);

public function upload() {
  $user = User::firstOrCreate(['id' => 1]);

  if (Input::hasFile('image')) {
    $user->saveMedia(Input::file('image'));
  }

  return Redirect::route('route');
}

$user->saveMedia(Input::file('profile_picture'), 'profile_picture');
$user->saveMedia(Input::file('background_image'), 'background_image');

// Retrieves every Media linked with the user
$all_media = $user->getMedia();

// Retrieve a specific Media
$profile_picture = $user->getMedia('profile_picture');

// Delete all media for a user
$user->deleteMedia();

// Delete specific media
$user->deleteMedia('profile_picture');