本文整理汇总了PHP中Map::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Map::findOrFail方法的具体用法?PHP Map::findOrFail怎么用?PHP Map::findOrFail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Map
的用法示例。
在下文中一共展示了Map::findOrFail方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
//
$map = Map::findOrFail($this->argument('map'));
$minimap = $map->minimap;
if (!$minimap->locked || $this->option('force')) {
// Call dibs on editing this minimap
$supernow = new Carbon();
$this->info('[' . Carbon::now() . '] Locking and processing map ' . $map->id);
$minimap->updated_at = new \DateTime();
$minimap->locked = true;
$minimap->save();
// Load the tiles. May take some time. =)
$tiles = Tile::where('mapid', $map->id)->where('posz', 7)->get();
// Prepare the canvas, maestro!
\OTWorlds\MinimapPainter::$filename = $minimap->path;
\OTWorlds\MinimapPainter::load($map->width, $map->height);
foreach ($tiles as $tile) {
\OTWorlds\MinimapPainter::paint(intval($tile->posx), intval($tile->posy), intval($tile->itemid));
}
// Finish up
\OTWorlds\MinimapPainter::save();
// Let other processes edit this map again
$minimap->locked = false;
$minimap->save();
$donenow = new Carbon();
$this->info('[' . $donenow->now() . '] Done. Processed ' . $tiles->count() . ' tiles in ' . $donenow->diffInSeconds($supernow) . ' seconds.');
} else {
$this->error('Minimap is locked. Either another process is using it, or the last one crashed. Use --force to ignore.');
}
}
示例2: queuePaint
/**
* Non-static method for the Laravel Queue handler
*/
public function queuePaint($job, $data)
{
$map = Map::findOrFail($data['mapid']);
self::$filename = $map->minimap->path;
self::load();
foreach ($data['tiles'] as $tile) {
if (intval($tile['z']) == 7) {
self::paint(intval($tile['x']), intval($tile['y']), intval($tile['itemid']));
}
}
self::save();
$job->delete();
}
示例3: getMinimap
public function getMinimap($mapid)
{
$mapid = intval($mapid);
$map = Map::findOrFail($mapid);
//Enforce ACL
if (!$this->userCanView($map)) {
App::abort(403);
}
$minimap_path = $map->minimap->path;
$png = file_get_contents($minimap_path);
return Response::make($png, 200, array('content-type' => 'image/png'));
}