PHP code example of plank / laravel-mediable

1. Go to this page and download the library: Download plank/laravel-mediable 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/ */

    

plank / laravel-mediable example snippets


$media = MediaUploader::fromSource($request->file('thumb'))
	->toDestination('uploads', 'blog/thumbnails')
	->upload();

$post = Post::create($this->request->input());
$post->attachMedia($media, ['thumbnail']);

$post->getMedia('thumbnail')->first()->getUrl();

'providers' => [
    ...
    Plank\Mediable\MediableServiceProvider::class,
    ...
];

'aliases' => [
	...
    'MediaUploader' => Plank\Mediable\MediaUploaderFacade::class,
    ...
]
bash
php artisan vendor:publish --provider="Plank\Mediable\MediableServiceProvider"
bash
php artisan migrate