PHP code example of mcleanka / laravel-file-manager

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

    

mcleanka / laravel-file-manager example snippets


class User extends Authenticatable implements HasMedia
{
    use InteractsWithMedia, ...MoreTraits;
    ...
}

namespace App\Classes;

use Spatie\MediaLibrary\MediaCollections\Models\Media;
use Spatie\MediaLibrary\Support\PathGenerator\PathGenerator;

class CustomPathGenerator implements PathGenerator
{
    public function getPath(Media $media): string
    {
        $user = auth()->user();

        return request()->get('path') ?? 'archive' . '/' . $user->name . '/';
    }

    public function getPathForConversions(Media $media): string
    {
        return $this->getPath($media) . 'conversions/';
    }

    public function getPathForResponsiveImages(Media $media): string
    {
        return $this->getPath($media) . 'responsive/';
    }
}

'path_generator' => App\Classes\CustomPathGenerator::class,