/**
* @return \Illuminate\Http\Response
*/
public function index()
{
// Use content negotiation to determine the correct format to return
$negotiator = new \Negotiation\FormatNegotiator();
$acceptHeader = Request::header('accept');
// Set priorities to json (if the app requests json provide it in favor of html)
$priorities = array('application/json', 'text/html', '*/*');
// Get the best appropriate content type
$result = $negotiator->getBest($acceptHeader, $priorities);
// Default to html if $result is not set
$val = "text/html";
if (isset($result)) {
$val = $result->getValue();
}
// See what kind of content we should return
switch ($val) {
case "text/html":
// In case we want to return html, just let
// Laravel render the view and send the headers
return Response::view('route.planner')->header('Content-Type', "text/html")->header('Vary', 'accept');
break;
case "application/json":
default:
// In case we want to return JSON(LD) or something else, generate
// our JSON by calling our static function 'getJSON()'
return Response::make($this::getJSON())->header('Content-Type', "application/json")->header('Vary', 'accept');
break;
}
}