本文整理汇总了PHP中app\App::abort方法的典型用法代码示例。如果您正苦于以下问题:PHP App::abort方法的具体用法?PHP App::abort怎么用?PHP App::abort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\App
的用法示例。
在下文中一共展示了App::abort方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: scopeGetPage
public function scopeGetPage($query, $slug)
{
$query = $query->where('slug', '=', $slug)->firstOrFail();
if (!$query) {
App::abort(404);
} else {
return $query;
}
}
示例2: export
/**
* Shell out to phantomjs to take a screenshot of our chart + download the svg
*
* @param string $slug The chart slug to export.
* @param int $width Desired width in pixels of the exported image.
* @param int $height Desired height in pixels of the exported image.
* @param string $format Either "svg" or "png". Both will be saved, only affects return
* @return string Path to exported file.
*/
public static function export($slug, $query, $width, $height, $format)
{
$phantomjs = base_path() . "/node_modules/.bin/phantomjs";
$rasterize = base_path() . "/phantomjs/rasterize.js";
$target = \Request::root() . "/" . $slug . ".export" . "?" . $query;
$queryHash = hash('md5', $query);
$pngFile = public_path() . "/exports/" . $slug . "-" . $queryHash . ".png";
$returnFile = public_path() . "/exports/" . $slug . "-" . $queryHash . "." . $format;
if (!file_exists($returnFile)) {
$command = $phantomjs . " " . $rasterize . " " . escapeshellarg($target) . " " . escapeshellarg($pngFile) . " '" . $width . "px*" . $height . "px'" . " 2>&1";
Log::info($command);
exec($command, $output, $retval);
if ($retval != 0) {
return \App::abort(406, json_encode($output));
}
}
return $returnFile;
}