public function get_army_profile($armyid = NULL) { //Can't look up nothing... if ($armyid == NULL) { return Response::error('404'); } //Select only the latest army $army = Army::with('armymembers')->where('armyId', '=', $armyid)->order_by('version', 'DESC')->first(); //somehow no army was found? why not search box? //or army newly created and not up to date if (!$army) { return Response::error('404'); } //try to determine the army tag based off player data $tag = Player::where(function ($query) use($army) { $query->where('armyId', '=', $army->armyid); $query->where('armyTag', '>', "''"); })->order_by('updated_at', 'DESC')->first(); return View::make('player.army_profile')->with('title', 'Profile for ' . htmlentities($army->name))->with(compact('army'))->with(compact('tag')); }