/** * Get all posts grouped by create date. * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function groupByDate() { $posts = $this->post->all(); $group = []; foreach ($posts as $post) { $date = date_parse($post->created_at); $mYear = $date['year']; $mMonth = $date['month']; // Month or Year not exists current. if (!array_key_exists($mYear, $group)) { $group[$mYear] = []; } if (!array_key_exists($mMonth, $group[$mYear])) { $group[$mYear][$mMonth] = []; } array_push($group[$mYear][$mMonth], $post); } return view('front.archive.date', compact('group')); }
/** * Display a listing of the resource. * * @return \Illuminate\View\View */ public function index() { $posts = $this->posts->all(); return view('backend.posts.index', compact('posts')); }
/** * Display a listing of the resource. * * @return Response */ public function index() { return $this->postRepository->all(); }
/** * Display a list of all posts. * * @return \Illuminate\Http\JsonResponse */ public function index() { return view('landing', ['posts' => $this->posts->all(['orderBy' => 'created_at', 'sortOrder' => 'desc'])]); }
/** * Display a list of posts ordered by votes * * @param Request $request * @return Response */ public function index(Request $request) { return view('posts.index', ['posts' => $this->posts->all()]); }
/** * Get all posts and make pagination. * * @return \Illuminate\Http\Response */ public function index() { $posts = $this->blog->all(setting('post_per_page')); $links = $posts->links(); return compact('posts', 'links'); }