当前位置: 首页>>代码示例>>PHP>>正文


PHP Article::orderBy方法代码示例

本文整理汇总了PHP中app\Article::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::orderBy方法的具体用法?PHP Article::orderBy怎么用?PHP Article::orderBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Article的用法示例。


在下文中一共展示了Article::orderBy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 /**
  * 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);
 }
开发者ID:becast,项目名称:GameReviewSite,代码行数:12,代码来源:HomeController.php

示例2: index

 /**
  * 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));
 }
开发者ID:Hukuta,项目名称:laravel-blog,代码行数:35,代码来源:ArticlesController.php

示例3: getPaginated

 public function getPaginated(array $params)
 {
     if ($params['sortBy'] || $params['order']) {
         return Article::orderBy($params['sortBy'], $params['order'])->paginate(10);
     }
     return Article::paginate(10);
 }
开发者ID:myleshyson,项目名称:ivgainesville,代码行数:7,代码来源:PostsRepo.php

示例4: getHome

 /**
  * 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]);
 }
开发者ID:pshanoop,项目名称:laravel-blog,代码行数:12,代码来源:HomeController.php

示例5: index

 public function index()
 {
     $categories = $this->categories();
     $articles = Article::orderBy('id', 'desc')->paginate(8);
     $tags = Tag::all();
     return view('home.index', compact('articles', 'categories', 'tags'));
 }
开发者ID:axhello,项目名称:laravel-blog-demo,代码行数:7,代码来源:HomeController.php

示例6: index

 /**
  * 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));
     //显示首页
 }
开发者ID:jew977,项目名称:laravelhub,代码行数:12,代码来源:HomeController.php

示例7: getForum

 /**
  * 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]);
 }
开发者ID:weiyeu,项目名称:laravel_date,代码行数:12,代码来源:ArticleController.php

示例8: index

 public function index()
 {
     $articles = Cache::rememberForever('article:all', function () {
         return Article::orderBy('created_at', 'asc')->get();
     });
     return view('article.index', ['articles' => $articles]);
 }
开发者ID:anti-social,项目名称:vagga,代码行数:7,代码来源:ArticleController.php

示例9: index

 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'));
 }
开发者ID:Panfen,项目名称:mango,代码行数:27,代码来源:HomeController.php

示例10: index

 /**
  * 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]);
 }
开发者ID:phantsang,项目名称:1u0U39rjwJO4Vmnt99uk9j6,代码行数:13,代码来源:ArticlesController.php

示例11: comart

 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;
 }
开发者ID:todayqq,项目名称:TodayBlog,代码行数:8,代码来源:Article.php

示例12: getIndex

 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]);
 }
开发者ID:sylvanasGG,项目名称:laravel_lte,代码行数:8,代码来源:HomeController.php

示例13: getIndex

 /**
  * @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');
 }
开发者ID:sylvanasGG,项目名称:laravel_lte,代码行数:12,代码来源:ArticleController.php

示例14: 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'));
 }
开发者ID:Jako81624,项目名称:GameReviewSite,代码行数:13,代码来源:ArticleController.php

示例15: index

 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'));
 }
开发者ID:cihannalp,项目名称:Laravel-Blog,代码行数:8,代码来源:ArticleController.php


注:本文中的app\Article::orderBy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。