}); //Route::get('topics', 'TopicController'); Route::group(array('prefix' => 'api/v1'), function () { Route::resource('getTopics', 'TopicAPIController'); }); Response::macro('xml', function ($vars, $status = 200, array $header = array(), $rootElement = 'response', $xml = null) { if (is_object($vars) && $vars instanceof Illuminate\Support\Contracts\ArrayableInterface) { $vars = $vars->toArray(); } if (is_null($xml)) { $xml = new SimpleXMLElementExtended('<' . $rootElement . '/>'); } foreach ($vars as $key => $value) { if (is_array($value)) { if (is_numeric($key)) { Response::xml($value, $status, $header, $rootElement, $xml->addChild(str_singular($xml->getName()))); } else { Response::xml($value, $status, $header, $rootElement, $xml->addChild($key)); } } else { $xml->addChildWithCDATA($key, $value); } } if (empty($header)) { $header['Content-Type'] = 'application/xml'; } return Response::make($xml->asXML(), $status, $header); }); class SimpleXMLElementExtended extends SimpleXMLElement { /**