/**
  * Display a listing of the resource.
  *
  * @param Request $r
  * @return \Illuminate\Http\Response
  */
 public function index(Request $r)
 {
     $withChildren = (bool) $r->get('withChildren', false);
     if ($withChildren) {
         $root = Node::all()->toHierarchy();
     } else {
         $root = Node::roots()->get();
     }
     return Response::json($root);
 }