PHP code example of mitydigital / fuse-utilities

1. Go to this page and download the library: Download mitydigital/fuse-utilities 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/ */

    

mitydigital / fuse-utilities example snippets




namespace App\Images;

use App\Support\Product;
use MityDigital\FuseUtilities\Contracts\ImageUrlGenerator;
use MityDigital\FuseUtilities\Support\StatamicImageUrlGenerator;
use Statamic\Contracts\Assets\Asset;
use Statamic\Support\Str;

class ProjectImageUrlGenerator implements ImageUrlGenerator
{
    public function __construct(
        private StatamicImageUrlGenerator $defaultGenerator,
    ) {}

    public function generate(Asset $asset, array $params = []): string
    {
        if ($asset->container()->handle() !== 'private') {
            return $this->defaultGenerator->generate($asset, $params);
        }

        return url()->temporarySignedRoute('account.child.asset.image',
            now()->addHours(2),
            [
                'asset' => Str::toBase64Url($asset->id()),
                /* any other params that need to be added */
                ...$params,
            ]);
    }
}

use App\Images\ProjectImageUrlGenerator;
use MityDigital\FuseUtilities\Contracts\ImageUrlGenerator;

$this->app->bind(ImageUrlGenerator::class, ProjectImageUrlGenerator::class);
shell
php artisan fuse:path-references