/** * Show the profile for the given user. * * @param int $id * @return Response */ public function showLocation($id) { $location = Location::findOrFail($id); $transformer = new \App\ViewHelpers\DirectionJsonTransformer(); $directionInJsonFormat = $transformer->getDirectionsAsJson($location->directions); return view('location', ['location' => $location, 'directions' => $directionInJsonFormat]); }
public function handle() { $this->info('Scheduling annotation for existing locations.'); Location::all()->each(function (Location $l) { $this->line("{$l->human_name}"); $this->dispatch(new AnnotateLocation($l)); }); }
public function get(APIRequest $request, $id) { $location = Location::findOrFail($id); $resource = new Item($location, new LocationTransformer(), 'location'); return $this->fractal->createData($resource)->toArray(); }
/** * Execute the console command. * * @return mixed */ public function handle() { $this->info('Deleting old locations'); Location::truncate(); $this->info('Deleting old directions'); Direction::truncate(); $this->info('Creating new locations'); $cave = new Location(); $cave->id = 1; $cave->name = 'cave'; $cave->image_name = 'cave.jpg'; $shoreMountains = new Location(); $shoreMountains->id = 2; $shoreMountains->name = 'shore mountains'; $shoreMountains->image_name = 'shore_mountains.jpg'; $caveEntrance = new Location(); $caveEntrance->id = 3; $caveEntrance->name = 'cave entrance'; $caveEntrance->image_name = 'cave_entrance.jpg'; $castle = new Location(); $castle->id = 4; $castle->name = 'castle'; $castle->image_name = 'castle.jpg'; $westBeach = new Location(); $westBeach->id = 5; $westBeach->name = 'west beach'; $westBeach->image_name = 'west_beach.jpg'; $forest = new Location(); $forest->id = 6; $forest->name = 'forest'; $forest->image_name = 'forest.jpg'; $valley = new Location(); $valley->id = 7; $valley->name = 'valley'; $valley->image_name = 'valley.jpg'; $cottage = new Location(); $cottage->id = 8; $cottage->name = 'cottage'; $cottage->image_name = 'cottage.jpg'; $shipwreckBeach = new Location(); $shipwreckBeach->id = 9; $shipwreckBeach->name = 'shipwreck beach'; $shipwreckBeach->image_name = 'shipwreck_beach.jpg'; $fishermanVillage = new Location(); $fishermanVillage->id = 10; $fishermanVillage->name = 'fisherman village'; $fishermanVillage->image_name = 'fisherman_village.jpg'; $cave->save(); $shoreMountains->save(); $caveEntrance->save(); $castle->save(); $westBeach->save(); $forest->save(); $valley->save(); $cottage->save(); $shipwreckBeach->save(); $fishermanVillage->save(); $this->createDirectionNorthToSouth($shoreMountains, $westBeach); $this->createDirectionNorthToSouth($cave, $caveEntrance); $this->createDirectionNorthToSouth($caveEntrance, $forest); $this->createDirectionNorthToSouth($forest, $shipwreckBeach); $this->createDirectionNorthToSouth($castle, $valley); $this->createDirectionNorthToSouth($valley, $fishermanVillage); $this->createDirectionWestToEast($shoreMountains, $caveEntrance); $this->createDirectionWestToEast($caveEntrance, $castle); $this->createDirectionWestToEast($westBeach, $forest); $this->createDirectionWestToEast($forest, $valley); $this->createDirectionWestToEast($valley, $cottage); $this->createDirectionWestToEast($shipwreckBeach, $fishermanVillage); }
/** * @param $info * @return Location **/ protected function createLocation($info) { // TODO: validate input types $loc = Location::create(['human_name' => $info['location']['human_name']]); if (isset($info['location']['human_street_address'])) { $loc->human_street_address = $info['location']['human_street_address']; } if (isset($info['location']['lat'])) { $loc->lat = $info['location']['lat']; } if (isset($info['location']['lon'])) { $loc->lon = $info['location']['lon']; } if (isset($info['location']['url'])) { $loc->url = $info['location']['url']; } $loc->save(); return $loc; }