本文整理汇总了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);
}
示例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));
}
示例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);
}
示例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]);
}
示例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'));
}
示例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));
//显示首页
}
示例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]);
}
示例8: index
public function index()
{
$articles = Cache::rememberForever('article:all', function () {
return Article::orderBy('created_at', 'asc')->get();
});
return view('article.index', ['articles' => $articles]);
}
示例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'));
}
示例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]);
}
示例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;
}
示例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]);
}
示例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');
}
示例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'));
}
示例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'));
}