當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Article::search方法代碼示例

本文整理匯總了PHP中app\Article::search方法的典型用法代碼示例。如果您正苦於以下問題:PHP Article::search方法的具體用法?PHP Article::search怎麽用?PHP Article::search使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Article的用法示例。


在下文中一共展示了Article::search方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: index

 public function index(urlRequest $request)
 {
     //query
     if ($search = $request->query('q')) {
         $articles = Article::search($search)->orderBy('created_at', 'desc')->simplepaginate(18);
     } elseif ($search = $request->query('id')) {
         //查找偽id(photo)
         $search = \App\Article::where('photo', $search)->firstOrFail()->id;
         $articles = DB::table('articles')->where('id', '<=', $search)->orderBy('created_at', 'desc')->simplepaginate(18);
         //偽搜索結果
         $search = $request->query('id');
     } else {
         //DB::代替Article::
         $articles = DB::table('articles')->orderBy('created_at', 'desc')->simplepaginate(18);
     }
     //已經點讚{!!$articles->appends(Request::except('page'))->render()!!}
     //$f = DB::table('votes')->whereuser_id(Auth::user()->id)->lists('votable_id');
     //http://example.com/custom/url?page=N, you should pass custom/url to the setPath
     $articles->setPath('articles');
     //sidebar
     $hotimgs = \App\Article::where('type', 'LIKE', "%jpg%")->orderBy('vote_count', 'desc')->take(10)->get();
     //return $hotimgs;
     $hotreplies = \App\Reply::orderBy('vote_count', 'desc')->limit(10)->get();
     return view('articles.index', compact('articles', 'search', 'hotimgs', 'hotreplies'));
 }
開發者ID:stevejobsii,項目名稱:phphub-laravel5.1,代碼行數:25,代碼來源:ArticlesController.php

示例2: index

 public function index(Request $request)
 {
     $arts = Article::search($request->title)->orderBy('id', 'DESC')->paginate(5);
     $arts->each(function ($arts) {
         $arts->category;
         $arts->user;
     });
     return view('admin.articles.index')->with('arts', $arts);
 }
開發者ID:gratereaux,項目名稱:practicing-laravel,代碼行數:9,代碼來源:ArticlesController.php

示例3: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $articles = Article::search($request->title)->desc()->paginado();
     $articles->each(function ($articles) {
         $articles->category;
         $articles->user;
     });
     return view('admin.articles.index')->with('articles', $articles);
 }
開發者ID:SanDroid77,項目名稱:Blog-Laravel,代碼行數:14,代碼來源:ArticlesController.php

示例4: GIF

 public function GIF(urlRequest $request)
 {
     if ($search = $request->query('q')) {
         $articles = \App\Article::search($search)->where('type', '.mp4')->orderBy('created_at', 'desc')->simplepaginate(18);
     } elseif ($search = $request->query('id')) {
         $search = \App\Article::where('photo', $search)->firstOrFail()->id;
         $articles = DB::table('articles')->where('type', '.mp4')->where('id', '<=', $search)->orderBy('created_at', 'desc')->simplepaginate(18);
         $search = $request->query('id');
     } else {
         $articles = DB::table('articles')->where('type', '.mp4')->orderBy('created_at', 'desc')->simplepaginate(18);
     }
     $articles->setPath('GIF');
     $hotimgs = \App\Article::where('type', 'LIKE', "%jpg%")->orderBy('vote_count', 'desc')->take(10)->get();
     $hotreplies = \App\Reply::orderBy('vote_count', 'desc')->limit(10)->get();
     return view('articles.index', compact('articles', 'search', 'hotimgs', 'hotreplies'));
 }
開發者ID:stevejobsii,項目名稱:gg,代碼行數:16,代碼來源:TagsController.php

示例5: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $articles = Article::search($request->title)->orderBy('created_at', 'DESC')->paginate(8);
     return view('admin.articles.index', compact('articles'));
 }
開發者ID:JhonatanC,項目名稱:laravelcodfa,代碼行數:10,代碼來源:ArticlesController.php


注:本文中的app\Article::search方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。