public static function getImageUrl($path)
    {
        $disk = config('filesystems.default');
        #Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' .
        #    'Get Image URL for path = ' . $path);

        /** @var \Illuminate\Filesystem\FilesystemAdapter $storage */
        $storage = Storage::disk($disk);

        // Check that the path is valid
        if (! $storage->exists($path)) {
            return '';
        }

        #Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' .
        #    'Filesystem driver = ' . $disk);
        switch ($disk) {
            case 's3':
                /** @var Filesystem $driver */
                $driver = $storage->getDriver();

                /** @var AwsS3Adapter $adapter */
                $adapter = $driver->getAdapter();

                /** @var S3Client $client */
                $client = $adapter->getClient();
                $bucket = config('filesystems.disks.s3.bucket');
                $url    = $client->getObjectUrl($bucket, $path);
                #Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' .
                #    'URL = ' . $url);
                return $url;
                break;

            case 'local':
                return config('url') . '/' . $path;
                break;

            default:
                return static::getRawImage($path);
                break;
        }
    }
public static function getImageUrl($path)
    {
        $disk = config('filesystems.default');
        #Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' .
        #    'Get Image URL for path = ' . $path);

        /** @var \Illuminate\Filesystem\FilesystemAdapter $storage */
        $storage = Storage::disk($disk);

        // Check that the path is valid
        if (! $storage->exists($path)) {
            return '';
        }

        #Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' .
        #    'Filesystem driver = ' . $disk);
        switch ($disk) {
            case 's3':
                /** @var Filesystem $driver */
                $driver = $storage->getDriver();

                /** @var AwsS3Adapter $adapter */
                $adapter = $driver->getAdapter();

                /** @var S3Client $client */
                $client = $adapter->getClient();
                $bucket = config('filesystems.disks.s3.bucket');
                $url    = $client->getObjectUrl($bucket, $path);
                #Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' .
                #    'URL = ' . $url);
                return $url;
                break;

            case 'local':
                return config('url') . '/' . $path;
                break;

            default:
                return static::getRawImage($path);
                break;
        }
    }
public static function getImageUrl ( $ path ) { $ disk = config ( 'filesystems.default' ) ; #Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' . #    'Get Image URL for path = ' . $path); /** @var \Illuminate\Filesystem\FilesystemAdapter $storage */ $ storage = Storage :: disk ( $ disk ) ; // Check that the path is valid if ( ! $ storage -> exists ( $ path ) ) { return '' ; } #Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' . #    'Filesystem driver = ' . $disk); switch ( $ disk ) { case 's3' : /** @var Filesystem $driver */ $ driver = $ storage -> getDriver ( ) ; /** @var AwsS3Adapter $adapter */ $ adapter = $ driver -> getAdapter ( ) ; /** @var S3Client $client */ $ client = $ adapter -> getClient ( ) ; $ bucket = config ( 'filesystems.disks.s3.bucket' ) ; $ url = $ client -> getObjectUrl ( $ bucket , $ path ) ; #Log::debug(__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' . #    'URL = ' . $url); return $ url ; break ; case 'local' : return config ( 'url' ) . '/' . $ path ; break ; default : return static :: getRawImage ( $ path ) ; break ; } }
Get image URL attribute based on its path on file storage

@param $path string
@return string
@link https://stackoverflow.com/questions/25323753/laravel-league-flysystem-getting-file-url-with-aws-s3
Get image URL attribute based on its path on file storage