1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/app/Helpers/GenerateUrl.php
Benjamin Beganović 69fa60b91c
Added generateUrl method for getting assets (#3258)
* Added generateUrl method for getting assets

* Fix return types
2020-01-29 13:31:34 +11:00

32 lines
682 B
PHP

<?php
use App\Models\Document;
use Illuminate\Support\Facades\Storage;
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
/**
* Generate url for the asset.
*
* @param Document $document
* @param boolean $absolute
* @return string|null
*/
function generateUrl(Document $document, $absolute = false)
{
$url = Storage::disk($document->disk)->url($document->path);
if($url && $absolute) return url($url);
if ($url) return $url;
return null;
}