public function getAvailableUnits($id) { $file = file_get_contents("units.txt"); $units = json_decode($file, true); $position = Position::find($id); $x = $position->x; $y = $position->y; $position = Position::where('y', $y)->where('x', $x)->get()->lists('id'); $city = City::whereIn('position_id', $position)->get(); if (count($city) == 0) { return $city; } else { switch ($city[0]->tier) { case 1: $txt = 'tier1'; break; case 2: $txt = 'tier2'; break; } $units = Unit::whereIn('Id', $units[$txt])->with('resource')->get(); return \App\CityEffectApplier::modifyUnitPricesByCity($units, $city[0]); } }