PHP code example of creode / laravel-assets

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

    

creode / laravel-assets example snippets


return [

    /*
    |--------------------------------------------------------------------------
    | Disk
    |--------------------------------------------------------------------------
    |
    | This value is the name of the disk where assets will be stored. This can
    | be any disk that you have configured in your filesystems.php config file.
    |
    */

    'disk' => env('FILESYSTEM_DISK', 'public'),
];

$asset = new Creode\LaravelAssets\Models\Asset;

// You can get the asset location from disk using a path.
$asset->path;

// You can get the url property of the asset.
$asset->url;

namespace App\Generators;

use Creode\LaravelAssets\Generators\PDFThumbnailGenerator;

class EPSThumbnailGenerator implements ThumbnailGeneratorInterface
{
    /**
     * Generates a thumbnail url for an asset.
     */
    public function generateThumbnailUrl(Asset $asset): ?string {
        // Custom logic to generate a thumbnail for an EPS file.
    }

    /**
     * Gets the type of output this generator produces.
     */
    public function getOutputType(): string {
        return 'image'; // typically 'image' or 'icon'.
    }
}

// AppServiceProvider.php

namespace App\Providers;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    public function boot()
    {
        // Add an EPS thumbnail generator.
        $generator = resolve('assets.thumbnail.factory');

        $generator->addGenerator('image/x-eps', function () {
            return new \App\Generators\EPSThumbnailGenerator();
        });
    }
}
bash
php artisan vendor:publish --tag="assets-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="assets-config"