Created
August 29, 2022 16:46
-
-
Save mishajib/bfca80c53099727eb4183b8912eeb49f to your computer and use it in GitHub Desktop.
This helper helps to get image from public disk or AWS S3.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Get file from storage folder | |
if (!function_exists('storageLink')) { | |
function storageLink($url, $disk = 'public', $type = 'default') | |
{ | |
if (Storage::disk($disk)->exists($url)) { | |
if ($disk == 's3') { | |
return Storage::disk($disk)->temporaryUrl($url, now()->addMinute()); | |
} else { | |
return Storage::disk($disk)->url($url); | |
} | |
} else { | |
if ($type == 'user') { | |
return Storage::disk($disk)->url(config('settings.default_user_image')); | |
} | |
return Storage::disk($disk)->url(config('settings.default_image')); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment