Merge branch 'dev' into test.customwristbands.cz
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace App\Helpers;
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\Process\Exception\InvalidArgumentException;
|
||||
|
||||
class Template
|
||||
@@ -40,7 +41,37 @@ class Template
|
||||
return $view;
|
||||
}
|
||||
|
||||
public static function asset($path) {
|
||||
return env('SITE_URL').'/assets/'.config('app.theme').'/'.$path;
|
||||
/**
|
||||
* Get URL to uploaded file
|
||||
*
|
||||
* @param $filename
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function upload($filename)
|
||||
{
|
||||
// for debug environment check if file exists
|
||||
if (env('APP_DEBUG') && !file_exists(config('app.upload_path') . '/' . $filename)) {
|
||||
throw new NotFoundHttpException('File ' . $filename . ' cannot be found in ' . config('app.upload_path') . '.');
|
||||
}
|
||||
|
||||
// return url to uploaded file
|
||||
return config('app.upload_url') . '/' . $filename;
|
||||
}
|
||||
|
||||
public static function asset($path)
|
||||
{
|
||||
if (env('APP_DEBUG')) {
|
||||
if (empty($path)) {
|
||||
throw new InvalidArgumentException('No asset name defined!');
|
||||
}
|
||||
|
||||
// check if asset exists and is file
|
||||
if (!file_exists(public_path('assets/' . config('app.theme') . '/' . $path))) {
|
||||
throw new NotFoundHttpException('Cannot find any asset in ' . public_path('assets/' . config('app.theme') . '/' . $path) . '. Try to check your paths.');
|
||||
}
|
||||
}
|
||||
|
||||
return config('app.url') . '/assets/' . config('app.theme') . '/' . $path;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user