/** * Deleted checked news. */ public function index_onDelete() { if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) { foreach ($checkedIds as $newsId) { if (!($news = NewsModel::find($newsId))) { continue; } $news->delete(); } Flash::success(Lang::get('abnmt.mrc::lang.news.delete_selected_success')); } else { Flash::error(Lang::get('abnmt.mrc::lang.news.delete_selected_empty')); } return $this->listRefresh(); }
protected function loadPost() { $slug = $this->property('slug'); $post = PostModel::isPublished()->where('slug', $slug)->first(); if (!$post) { return null; } $prev = PostModel::isPublished()->where('published_at', '<', $post->published_at)->orderBy('published_at', 'desc')->first(); $next = PostModel::isPublished()->where('published_at', '>', $post->published_at)->orderBy('published_at', 'asc')->first(); if (!is_null($prev)) { $this->prev = $this->page['prev'] = $prev->setUrl('news/post', $this->controller); } if (!is_null($next)) { $this->next = $this->page['next'] = $next->setUrl('news/post', $this->controller); } \CW::info([$this->prev, $this->next]); // CW::info(['News' => $post]); return $post; }
/** * Load feed */ protected function loadFeed() { $posts = PostModel::with('cover')->getNewsFeed(['page' => $this->property('pageNumber'), 'perPage' => $this->property('postsPerPage'), 'search' => $this->searchParam]); /* * Add a "url" helper attribute for linking to each post and category */ $posts->each(function ($post) { $post->setUrl($this->postPage, $this->controller); }); // CW::info(['NewsFeed' => $posts]); return $posts; }