PHP code example of classic-o / nova-media-library

1. Go to this page and download the library: Download classic-o/nova-media-library 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/ */

    

classic-o / nova-media-library example snippets


composer isan vendor:publish --provider="ClassicO\NovaMediaLibrary\ToolServiceProvider"

php artisan migrate

php artisan storage:link

public function tools()
{
    return [
        new \ClassicO\NovaMediaLibrary\NovaMediaLibrary()
    ];
}

use ClassicO\NovaMediaLibrary\MediaLibrary;

class Post extends Resource
{
    ...
     public function fields(Request $request)
        {
            return [
                ...
                MediaLibrary::make('Image'),
                ...
            ];
        }
    ...
}

... Verifying access

$file = API::getFiles($id, null, true);
return API::getPrivateFile($file->path, request('img_size'))