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


PHP Article::orderBy方法代码示例

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


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

示例1: index

 /**
  * Show the application dashboard.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //banner
     $banners = Banner::orderBy('created_at', 'DESC')->take(7)->get();
     //最新
     $last_articles = Article::with('author')->orderBy('created_time', 'DESC')->take(12)->get();
     $hot_articles = Article::orderBy('views', 'DESC')->take(10)->get();
     return view('home', compact('banners', 'last_articles', 'hot_articles'));
 }
开发者ID:nutsdo,项目名称:nong-store,代码行数:14,代码来源:HomeController.php

示例2: listArticles

 /**
  * Lists the inserted articles
  * either by id, title or none.
  *
  * @param int $id
  * @param str $title
  * @param int $limit
  *
  * @throws Illuminate\Database\Eloquent\ModelNotFoundException
  *
  * @return array
  **/
 public function listArticles($id = null, $title = null, $limit = 20)
 {
     $query = Article::orderBy('created_at');
     if ($id) {
         return Article::findOrFail($id);
     }
     if ($title) {
         return $query->where('title', 'LIKE', '%' . $title . '%')->paginate($limit)->items();
     }
     return $query->paginate($limit)->items();
 }
开发者ID:TiagoMaiaL,项目名称:wiki,代码行数:23,代码来源:ArticlesRepository.php

示例3: index

 public function index()
 {
     $collection = Article::orderBy('updated_at')->get();
     // dd($collection);
     $collection->each(function ($model) {
         // var_dump($model->id);
         $model = $this->handleModelIndex($model);
     });
     // dd($collection->toArray());
     return $collection;
 }
开发者ID:gAb09,项目名称:NetP,代码行数:11,代码来源:ArticleG.php

示例4: show

 public function show($id)
 {
     Article::where('id', $id)->increment('views');
     //阅读量加1
     $article = Article::with(['comments' => function ($query) {
         $query->take(10);
     }])->find($id);
     //        dd($article);
     $views = Article::where('author_id', $article->author_id)->where('author_type', $article->author_type)->sum('views');
     $comments_count = Comment::where('article_id', $id)->count();
     $hots = Article::orderBy('views', 'desc')->take(10)->get();
     $is_like = false;
     $is_collection = false;
     $is_follow = false;
     if ($this->login_user) {
         $is_like = Like::where('user_id', $this->login_user->id)->where('like_type', 'article')->where('like_id', $id)->first();
         $is_collection = Collection::where('user_id', $this->login_user->id)->where('collection_type', 'article')->where('collection_id', $id)->first();
         $is_follow = DB::table('user_follow')->where('user_id', $this->login_user->id)->where('follow_id', $article->author_id)->first();
     }
     return view('front.article.index', compact('article', 'views', 'comments_count', 'hots', 'is_like', 'is_collection', 'is_follow'));
 }
开发者ID:nutsdo,项目名称:nong-store,代码行数:21,代码来源:ArticleController.php

示例5: all

 /**
  * display articles
  */
 public function all()
 {
     $articles = Article::orderBy('published_at', 'desc')->simplePaginate(7);
     return view('backend.articles', ['articles' => $articles, 'load_js' => 'backend/article.list']);
 }
开发者ID:kaiyulee,项目名称:express,代码行数:8,代码来源:ArticleController.php

示例6: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     return view('backend.article.index')->with(['items' => Article::orderBy('updated_at', 'desc')->paginate(20)]);
 }
开发者ID:whplay,项目名称:ohmate-shop,代码行数:9,代码来源:ArticleController.php

示例7: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $posts = Article::orderBy('created_at', 'DESC')->paginate(5);
     $data = compact('posts');
     return view('blog\\blog', $data);
 }
开发者ID:TenTail,项目名称:Laravel-Blog-Test,代码行数:11,代码来源:ArticlesController.php

示例8: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $articles = Article::orderBy('date_created', 'DESC')->paginate(20);
     return view('admin.articles.index', ['articles' => $articles]);
 }
开发者ID:scotthummel,项目名称:lambdaphx,代码行数:10,代码来源:ArticleController.php

示例9: function

        $data = \App\Models\Articles::where('id', '=', 11)->first();
        $data->article_title = 'update test -3-.';
        $data->feature = true;
        $data->save();
    }]);
    Route::get('delete', ['as' => 'ORM.delete', function () {
        $data = \App\Models\Articles::find(2);
        $data->delete();
        \App\Models\Articles::destroy(19, 20);
    }]);
});
Route::get('test', function () {
    // $data = \App\Models\Article::find(5);
    $data1 = \App\Models\Article::all();
    $data2 = \App\Models\Article::where('id', '>', 8);
    $data3 = \App\Models\Article::orderBy('id', 'DESC');
    dd([$data1, $data2, $data3]);
});
/*
Route::get('hello', function(){
	return "Hello World!";
});

Route::get('post/{id}', function($id) {
	return "id:".$id;
})->where('id', '[0-9]+');

// route name
Route::get('post2/{id?}', ['as' => 'post2.show', function($id = 0) {
	return "id:".$id;
}])->where('id', '[0-9]+');
开发者ID:TenTail,项目名称:Laravel-Blog-Test,代码行数:31,代码来源:routes.php

示例10: index

 public function index()
 {
     $articles = Article::orderBy('published_at', 'desc')->simplePaginate(7);
     return view('index', ['articles' => $articles]);
 }
开发者ID:kaiyulee,项目名称:express,代码行数:5,代码来源:IndexController.php

示例11: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $articles = Article::orderBy("id", "DESC")->paginate(20);
     return view("dashboard.articles.index", compact("articles"));
     //->with("message", $message);
 }
开发者ID:bassx1,项目名称:lessons,代码行数:11,代码来源:ArticlesController.php

示例12: index

 /**
  * Override index here because we want every article in the system
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $articles = Article::orderBy('id', 'desc')->paginate(15);
     return view('admin.article.index', compact('articles'));
 }
开发者ID:mattvb91,项目名称:website-laravel,代码行数:10,代码来源:ArticleController.php

示例13: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $articles = Article::orderBy('id', 'ASC')->paginate(15);
     return view('admin/articles/index')->with('articles', $articles);
 }
开发者ID:pcasanellasp,项目名称:bigseonetwork,代码行数:10,代码来源:ArticlesController.php

示例14: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $articles = Article::orderBy('created_at', 'desc')->take(10)->get();
     return view('articles.index')->with('articles', $articles);
 }
开发者ID:xiaoyang4011,项目名称:discuss,代码行数:10,代码来源:ArticlesController.php


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