/** * @param integer $year Year of the archive to find * @param array $filters Array of filters to apply on the collection * @return stdClass Object containing archive content data */ public function archivesData($year, $filters) { $archive = new ArticleArchiveCollection(); $archive->year = $year; $before = Carbon::create($year, 01, 01, 00, 00, 00); $after = Carbon::create($year + 1, 01, 01, 00, 00, 00); $archive->next = !Article::where('published_at', '>', $after)->get()->isEmpty(); $archive->previous = !Article::where('published_at', '<', $before)->get()->isEmpty(); $archive->months = $this->filter(Article::whereBetween('published_at', array($before, $after))->latest('published_at'), $filters)->get()->groupBy(function ($article) { return $article->published_at->format('M'); }); return $archive; }
public static function makePut($slug, ArticleRequest $request) { // todo: throw event $me = new static(); return $me->buildArticle($request, Article::whereSlug($slug)->firstOrFail()); }