当前位置: 首页>>代码示例>>PHP>>正文


PHP Map::findOrFail方法代码示例

本文整理汇总了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.');
     }
 }
开发者ID:Ablankzin,项目名称:OTWorlds,代码行数:36,代码来源:MinimapRefresh.php

示例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();
 }
开发者ID:Ablankzin,项目名称:OTWorlds,代码行数:16,代码来源:MinimapPainter.php

示例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'));
 }
开发者ID:Ablankzin,项目名称:OTWorlds,代码行数:12,代码来源:MapController.php


注:本文中的Map::findOrFail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。