PHP code example of xpeedstudio / laravel-medialibrary-mongodb

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

    

xpeedstudio / laravel-medialibrary-mongodb example snippets


$newsItem = News::find(1);
$newsItem->addMedia($pathToFile)->toMediaCollection('images');

$newsItem->addMedia($request->file('image'))->toMediaCollection('images');

$newsItem->addMedia($smallFile)->toMediaCollection('downloads', 'local');
$newsItem->addMedia($bigFile)->toMediaCollection('downloads', 's3');