Exemplo n.º 1
0
 public function getSearch()
 {
     $searchTerm = Input::get('s');
     $posts = Post::getPostsLike($searchTerm);
     $comments = Comment::getCommentsLike($searchTerm);
     $photos = Photo::getPhotosLike($searchTerm);
     $crafts = Craft::getCraftsLike($searchTerm);
     $tags = Tag::getTagsOrdered();
     // For Laravel 4.2 use getFactory() instead of getEnvironment() method.
     $posts->getEnvironment()->setViewName('pagination::slider');
     $posts->appends(['s' => $searchTerm]);
     $this->layout->with('title', trans('messages.Search') . ': ' . $searchTerm);
     if ($posts->isEmpty()) {
         $notFoundPosts = true;
     } else {
         $notFoundPosts = false;
     }
     if ($comments->isEmpty()) {
         $notFoundComments = true;
     } else {
         $notFoundComments = false;
     }
     if ($photos->isEmpty()) {
         $notFoundPhotos = true;
     } else {
         $notFoundPhotos = false;
     }
     if ($crafts->isEmpty()) {
         $notFoundCrafts = true;
     } else {
         $notFoundCrafts = false;
     }
     $this->layout->main = View::make('home', ['recentPosts' => $posts, 'allTags' => $tags])->nest('content', 'index_search', ['posts' => $posts, 'comments' => $comments, 'crafts' => $crafts, 'photos' => $photos, 'notFoundPosts' => $notFoundPosts, 'notFoundComments' => $notFoundComments, 'notFoundPhotos' => $notFoundPhotos, 'notFoundCrafts' => $notFoundCrafts]);
 }