exists($namespace . 'visitor.' . $prefix . $template)) { $view = $namespace . 'visitor.' . $prefix . $template; break; } } if (is_null($view)) { if ($throwExceptions) { throw new InvalidArgumentException('Cannot find template for ' . $namespace . $template); } else { return false; } } return $view; } /** * 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 thumbnail($filename) { // try to check if file have thumbnail if (file_exists(config('app.thumbnail_path') . '/' . $filename)) { $url = config('app.thumbnail_url') . '/' . $filename; } else { $url = self::upload($filename); } return $url; } /** * Get path to given asset * * @param $path * * @return string */ 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; } /** * Print date in configured format * * @param $datestamp * @param bool $withTime * * @return false|string */ public static function date($datestamp, $withTime = true) { $timestamp = strtotime($datestamp); if ($timestamp <= 0) { return ''; } $format = $withTime ? config('app.datetime_format') : config('app.date_format'); return date($format, $timestamp); } }