Example #1
0
 protected function listPosts()
 {
     $params = $this->params;
     /*
      * List all posts
      */
     $posts = EventModel::listFrontEnd($params);
     /*
      * Prepare for View
      */
     $active = Carbon::now();
     $posts->each(function ($post) use($params, &$active) {
         // Assign URLs
         extract($params);
         // if ($post->relation instanceof ArticleModel)
         //     $post->relation->setUrl($newsPage, $this->controller);
         if ($post->relation instanceof PerformanceModel) {
             $post->relation->setUrl($performancePage, $this->controller);
         }
         $date = Carbon::parse($post->event_date);
         if ($active != 'active' && $date->gte($active)) {
             $post->active = $active = 'active';
         }
         // Grouping
         if ($this->inCollection($post->relation->taxonomy, 'title', 'Детские спектакли')) {
             $this->group['child'][] = $post;
         } else {
             $this->group['normal'][] = $post;
         }
     });
     // CW::info($this->group);
     CW::info(['Events' => $posts]);
     return $posts;
 }