PHP code example of amjadiqbal / laravel-media-viewer

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

    

amjadiqbal / laravel-media-viewer example snippets


// config/media-viewer.php
'disks' => ['local', 'public', 's3'],

use AmjadIqbal\MediaViewer\Facades\MediaViewer;

MediaViewer::allows('s3', 'contracts/acme.pdf'); // disk, extension and Gate checks
MediaViewer::url('s3', 'contracts/acme.pdf');    // signed URL (default lifetime from config)
MediaViewer::url('s3', 'contracts/acme.pdf', 5); // ...valid for 5 minutes

// app/Providers/AppServiceProvider.php
Gate::define('viewMedia', function (?User $user, string $disk, string $path) {
    return $user && Document::where('path', $path)->where('team_id', $user->team_id)->exists();
});

// config/media-viewer.php
'gate' => 'viewMedia',
bash
php artisan vendor:publish --tag=media-viewer-config