/** * Registers view bindings * * @param NodeRepository $nodeRepository */ protected function registerViewBindings(NodeRepository $nodeRepository) { if (!is_installed()) { return; } if (!is_request_reactor()) { $home = $nodeRepository->getHome(false); view()->share('home', $home); } view()->composer('*', function ($view) { $view->with('currentUser', auth()->user()); }); if (is_request_reactor()) { view()->composer('partials.navigation.nodes', function ($view) { $leafs = empty($id = auth()->user()->home) ? Node::whereIsRoot()->defaultOrder()->get() : [Node::find($id)]; $view->with('leafs', $leafs); }); } }
/** * Shows the search page * * @param string $search * @param NodeRepository $nodeRepository * @param Request $request * @return View */ public function getSearch($search, NodeRepository $nodeRepository, Request $request) { set_app_locale_with('search', $search); $results = $nodeRepository->searchNodes($request->input('q')); return view('search', compact('results')); }