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'));
 }
 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);
 }
 /**
  * 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);
 }
示例#4
0
 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'));
 }
 /**
  * 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'));
 }