/** * Display a listing of the index resource. * * @return \Illuminate\Http\Response */ public function index() { /* * -------------------------------------------------------------------------- * Retrieve featured posts from Article model * -------------------------------------------------------------------------- * Headline : indicate article with headline state * Trending : indicate article with trending state * Popular : the top of post sort by most viewed on last 3 months * Ranked : the top of post sort by most stared * Latest : last published article */ $article = new Article(); $featured = $article->headline(); $trending = $article->trending(); $popular = $article->mostPopular(); $ranked = $article->mostRanked(); $latest = $article->latest(); /* * -------------------------------------------------------------------------- * Retrieve featured category * -------------------------------------------------------------------------- * Selecting the most viewed articles on top 4 categories */ $category = new Category(); $summary = $category->featured(); return view('pages.index', compact('featured', 'popular', 'ranked', 'trending', 'latest', 'summary')); }
/** * Display a listing of the headline article. * * @param Request $request * @return \Illuminate\Http\Response */ public function headline(Request $request) { /* * -------------------------------------------------------------------------- * Public headline article * -------------------------------------------------------------------------- * Retrieve full headline page (with false param), this page implement lazy * pagination then return json if page variable exists, return view if it * does not. */ $headline = $this->article->headline(false); $breadcrumb = ['Archive' => route('article.archive'), 'Headline' => route('article.headline')]; $next_ref = route('article.trending'); $prev_ref = route('article.latest'); if (Input::get('page', false) && $request->ajax()) { return $headline; } else { return view('article.category', compact('breadcrumb', 'next_ref', 'prev_ref')); } }