/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $data['articles'] = Article::orderBy('id', 'desc')->where('published', 1)->take(6)->get(); $data['jakoistrash'] = Article::orderBy('id', 'desc')->where('titletext', '!=', '')->where('published', 1)->where('featured', 1)->take(4)->get(); $data['writers'] = DB::table('writers')->orderByRaw("RAND()")->join('users', 'users.id', '=', 'writers.user_id')->get(); return view('pages.homepage', $data); }
/** * Display a listing of the resource. * * @param Request $request * @param int $page * @return Response */ public function index(Request $request, $page = 1) { // changing pagination page from route param Paginator::currentPageResolver(function () use($page) { return $page; }); // getting articles $articles = Article::orderBy('id', 'desc')->paginate(); // changing routing in rendered pagination view $pagination_view = $articles->render(); // from "/?page=$page" to "/page/$page" $pagination_view = preg_replace('|/(page/\\d+/?)?\\?page=(\\d+)|', '/page/$2', $pagination_view); // replace "/page/1" to "/" $pagination_view = str_replace('page/1"', '"', $pagination_view); //redirect from $_GET paging to new routing $_page = $request->get('page'); if ($_page && (string) abs($_page) === $_page) { if ($_page == 1) { return redirect('/'); } return redirect('/page/' . $_page); } // page title tag $page_title = 'Блог веб разработчика: php, linux и другое'; // ajax infinite scrolling or full html page $view = $request->ajax() ? 'articles.index-content' : 'articles.index'; return response()->view($view, compact('articles', 'page_title', 'pagination_view', 'page'))->withCookie($this->rating_cookie($request)); }
public function getPaginated(array $params) { if ($params['sortBy'] || $params['order']) { return Article::orderBy($params['sortBy'], $params['order'])->paginate(10); } return Article::paginate(10); }
/** * Display a listing of the resource. * * @return Response */ public function getHome($page = 1) { //Get articles per page $numPerPage = \Config::get('app.article_per_page'); $articles = Article::orderBy('created_at', 'desc')->simplePaginate($numPerPage); return View('home', ['articles' => $articles, 'isArticle' => false]); }
public function index() { $categories = $this->categories(); $articles = Article::orderBy('id', 'desc')->paginate(8); $tags = Tag::all(); return view('home.index', compact('articles', 'categories', 'tags')); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $article_all = Article::orderBy('created_at', 'DESC')->paginate(6); //dd($article_all); return view('Home.index', array('article_all' => $article_all)); //显示首页 }
/** * show front page of forum * * @return \Illuminate\Http\Response */ public function getForum() { // get articles $articles = Article::orderBy('updated_at', 'desc')->take(10)->get(); // return view with articles return view('articles.forum', ['articles' => $articles, 'article_type_hash' => $this->article_type_hash]); }
public function index() { $articles = Cache::rememberForever('article:all', function () { return Article::orderBy('created_at', 'asc')->get(); }); return view('article.index', ['articles' => $articles]); }
public function index() { $user = \Auth::user(); $time = $this->formatDate(); $action = 'home'; $r = Signin::where('user_id', \Auth::user()->id)->first(); $count = 0; $signined = false; if ($r) { $count = $r['count']; if (substr(Carbon::now(), 0, 10) == substr($r['last_signin'], 0, 10)) { $signined = true; } } $signinList = Signin::where('last_signin', 'like', substr(Carbon::now(), 0, 10) . '%')->orderBy('last_signin', 'desc')->get(); foreach ($signinList as &$item) { $item['last_signin'] = substr($item['last_signin'], 11, 8); } $cates = Cate::orderBy('count', 'desc')->limit(6)->get(); $authors = User::orderBy('score', 'desc')->limit(6)->get(); $teams = Team::limit(3)->get(); $recommendedArticles = Article::orderBy('recommend', 'deac')->limit(4)->get(); $phpArticles = Article::where('cate_id', 1)->limit(5)->get(); $todayHotArticles = Article::where('published_at', '>=', Carbon::now()->subDay(1))->where('published_at', '<=', Carbon::now())->orderBy('view', 'deac')->limit(6)->get(); $weekHotArticles = Article::where('published_at', '>=', Carbon::now()->subDay(7))->where('published_at', '<=', Carbon::now())->orderBy('view', 'deac')->limit(6)->get(); return view('home', compact('user', 'time', 'action', 'signin', 'minus', 'count', 'signined', 'signinList', 'cates', 'authors', 'teams', 'recommendedArticles', 'phpArticles', 'todayHotArticles', 'weekHotArticles')); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(Request $request) { $articles = Article::orderBy('priority')->get(); if ($request->ajax()) { return $articles->toArray(); } return view('admin.articles.index', ['articles' => $articles]); }
public static function comart() { $article = array(); $article['click'] = Article::orderBy('click', 'DESC')->with('cla')->skip(0)->take(6)->get(); $article['create'] = Article::orderBy('created_at', 'DESC')->with('cla')->skip(0)->take(6)->get(); $article['recommend'] = Article::orderBy('created_at', 'DESC')->where('recommend', '=', 1)->with('cla')->skip(0)->take(6)->get(); return $article; }
public function getIndex() { $mod = Article::orderBy('updated_at', 'desc'); $articles = $mod->paginate(3); // $this->assign('articles',$articles); // return $this->display('home.index'); return View('home.index', ['articles' => $articles]); }
/** * @param Request $request * @return \Illuminate\View\View */ public function getIndex(Request $request) { $mod = Article::orderBy('updated_at', 'desc'); $this->articleSearch($mod, $request); $articles = $mod->paginate(10); $this->assign('articles', $articles); return $this->display('admin.article.index'); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { if (!Permissions::check('article.list')) { abort(403); } $list = Article::orderBy('id', 'desc')->paginate(100); return view('pages.Backend.articlelist', compact('list')); }
public function index() { $user = new User(); $article = new Article(); $articles = $article->orderBy('updated_at', 'desc')->with('user')->get(); $users = $user->with('roles')->get(); return view('articles.articles', compact('articles', 'users')); }
/** * 首页 * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function index() { $articles = Article::orderBy('created_at', 'desc')->published()->paginate(3); // $articles = Article::with(['tags' => function($query){ // $query->where('tag_id', '<', '3'); // }])->where('id', '>', '1')->where('id', '<', '5')->get(); // dd($articles); return view('articles.lists', compact('articles')); }
public function show($id) { $articles = Article::find($id); $rcArticles = Article::orderBy('id', 'dsc')->take(5)->get(); $cmtArticles = ArticlesComment::all(); // dd($id); // dd($cmtArticles); return view('articles/show')->with(compact(['articles', 'cmtArticles', 'rcArticles'])); }
public function index() { $articles = Article::orderBy('id', 'DESC')->paginate(4); $articles->each(function ($articles) { $articles->category; $articles->images; }); return view('front.index')->with('articles', $articles); }
public function AddEvent($id = null) { $arts = Article::orderBy('id', 'desc')->select('id', 'title')->get(); foreach ($arts as $ar) { $articles[$ar->id] = '#' . $ar->id . ' - ' . $ar->title; } $event = Event::find($id); return view('admin.events.add', ['articles' => $articles, 'event' => $event]); }
/** * Display a listing of the resource. * * @return Response */ public function adminIndex($category = false) { if ($category != false) { $articles = Article::where('category_id', $category)->with('author', 'category')->orderBy('id', 'desc')->paginate(5); $category = Category::find($category)->name; } else { $articles = Article::orderBy('id', 'desc')->with('author', 'category')->paginate(5); } return view('admin.articles.index', compact('articles', 'category')); }
private function composeSidebar() { view()->composer('home.partials.sidebar', function ($view) { $allTags = \App\Tag::all(); $allCategories = \App\Category::getSortedCategories(); $NewestArticles = \App\Article::latest()->take(15)->get(); $hottestArticles = \App\Article::orderBy('click')->take(15)->get(); $view->with(compact('allTags', 'allCategories', 'NewestArticles', 'hottestArticles')); }); }
public static function getAllArticle() { //所有文章 $articles = Article::orderBy('updated_at', 'desc')->get(); $articleArr = []; foreach ($articles as $article) { $articleArr[$article->article_id] = str_limit($article->title, 15); } return $articleArr; }
/** * Get the articles home view * * @return view */ public function index() { //Note: all() returns an eloquenet collection. //Get articles with a publish date that is <= now $articles = Article::orderBy('published_at', 'desc')->published()->get(); //Get all articles //$articles = Article::orderBy('published_at', 'desc')->get(); //If you return the collection it will be cast to json. //return $articles; return view('articles.index', compact('articles')); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { if (Auth::user() && Auth::user()->rank == 'admin') { $articles = Article::orderBy('created_at', 'DESC')->take(5)->get(); $users = User::orderBy('created_at', 'DESC')->take(10)->get(); $tags = Tag::orderBy('created_at', 'DESC')->take(5)->get(); return view('admin.index', compact('articles', 'users', 'tags')); } else { return redirect('/')->with('error', 'You are not authorized to access that page.'); } }
public function viewArticle() { $articles = Article::orderBy('created_at', 'DESC')->paginate(4); /** * un recorrido para llamar a la relación (se realiza cuando se trabaja de muchos a muchos) */ $articles->each(function ($articles) { $articles->category; $articles->images; }); return view('front.article', compact('articles')); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function home() { $all = Category::where('parent', '=', 0); $fullcat = Category::get(); $allarticles = Article::orderBy('id', 'desc')->take(10)->get(); $alllessons = Lesson::groupBy('categories_id')->orderBy('id', 'desc')->take(10)->get(); $newsallarticles = Article::where('stat', '=', 'nouvelles')->orderBy('id', 'desc')->take(3)->get(); $bacallarticles = Article::where('stat', '=', 'apres-bac')->orderBy('id', 'desc')->take(3)->get(); $lessons = Lesson::all(); $partners = Partner::all(); return view(proj . '.home', ['title' => trans('accueil.accueil'), 'asccat' => $all->get(), 'allcat' => $all->orderBy('id', 'desc')->get(), 'fullcat' => $fullcat, 'allarticles' => $allarticles, 'newsallarticles' => $newsallarticles, 'bacallarticles' => $bacallarticles, 'partners' => $partners, 'alllessons' => $alllessons])->with('lessons', $lessons); }
/** * Display a listing of the resource. * * @return Response */ public function index(Cat $cats, Request $request) { $record_items = $cats->select('id')->post(2)->get(); //dump(array_pluck($record_items,'id')); $cats = $cats->select('id', 'name', 'parent')->posts(array_pluck($record_items, 'id'))->orderBy('name')->get(); //get_cat_by_parents([55,56]); foreach ($cats as $c) { $this->children[] = $c['id']; } $articles = !filter_request($request, 'a_filter') ? Article::orderBy('status', 'asc')->orderBy('published_at', 'desc')->latest('status')->orderall($this->children)->paginate(get_setting('pagination_num')) : Article::orderBy('status', 'asc')->orderBy('published_at', 'desc')->orderall($this->children)->filter($request, 'a_')->paginate(get_setting('pagination_num')); return view('admin.articles.index', compact('articles', 'request', 'query', 'cats')); }
public function index() { /*$redis = new Redis(); $redis->connect('localhost', 6379); $redis->set('demo', 'Thử', 10); //10 giây return $redis->get('demo');*/ /* $memcache = new Memcache(); $memcache->connect('localhost', 11211) or die ("Could not connect"); $memcache->set('demo', 'Demo', false, 1); return $memcache->get('demo');*/ $listCategory = Category::all(["id", "category_alias", "category_name"])->toArray(); $listArticle = Article::orderBy('created_date', 'desc')->paginate(3); return view('front.blog.index', compact('listCategory', 'listArticle')); }
/** * Display a listing of the resource. * * @return Response */ public function index() { // if (!Cache::has('articles')) // { // $articles = Article::remember(5)->paginate(10)->get(); // } else { // $articles = Cache::get('articles'); // } $articles = Article::orderBy('created_at', 'DESC')->get(); //$articles->setPath('articles'); $categories = Category::all(); $tags = Tag::all(); return view('articles.index', compact('articles', 'categories', 'tags')); }
public function Home(Request $request) { $page = (int) ($request->get('p', '1') > 0 ? $request->get('p', '1') : 1); $isPageMax = false; $articles = Article::orderBy('publish_at', 'desc')->orderBy('id', 'desc')->skip(($page - 1) * 10)->take(10)->get(); if (count($articles) == 0 && $page > 1) { $pagemax = ceil(Article::count() / 10); return Redirect::route('adminArticles', array('p' => $pagemax)); } $nextArticles = Article::orderBy('publish_at', 'desc')->orderBy('id', 'desc')->skip($page * 10)->take(1)->get(); if (count($nextArticles) == 0) { $isPageMax = true; } return view('admin.articles.home', compact('page', 'isPageMax', 'articles')); }