/**
  * @param $view
  * @param $model
  * @return $this
  */
 protected function renderView($view, $model)
 {
     return View::make(Layouts::getLayout(Layouts::byDomain(Request::getHost())))->with($model)->nest("content", $this->getView($view), $model);
 }
 public function upsertPage()
 {
     $pageId = Input::get("pageid");
     if ($pageId != null && strlen(trim($pageId)) > 0) {
         $page = $this->pageRepository->find($pageId);
     }
     if (!isset($page) || $page == null) {
         $page = new Page();
     }
     $langCode = Input::get("lang");
     $lang = $this->langRepository->findByCode($langCode);
     if ($lang != null) {
         $page->setLang($lang);
     }
     $page->setSlug(trim(Input::get("pageurl")));
     $page->setContent(trim(Input::get("content")));
     $page->setTitle(Input::get("title"));
     $page->setKeywords(Input::get("keywords"));
     $page->setDomain(trim(Input::get("domain")));
     $page->setDescription(Input::get("pagedescription"));
     $page->setLayout(Layouts::byDomain($page->getDomain()));
     if ($page->getId() == null) {
         $this->pageRepository->create($page);
     } else {
         $this->pageRepository->update($page);
     }
     return \Redirect::to("/admin/site/pagini-web");
 }