public function getMatch() { $match_id = Request::input('mp'); if (present($match_id)) { $match = Match::with('games.scores')->where('match_id', $match_id)->get(); if (!$match->isEmpty()) { return Response::json(json_collection($match, new MatchTransformer(), 'games.scores')[0]); } } // match existing api return Response::json(['match' => 0, 'games' => []]); }