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


PHP Poll::orderBy方法代码示例

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


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

示例1: getIndex

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function getIndex()
 {
     if (Session::get('user_level') < Config::get('cms.viewPolls')) {
         return Redirect::to(_l(URL::action('AdminHomeController@getIndex')))->with('message', Lang::get('admin.notPermitted'))->with('notif', 'warning');
     }
     $this->setLayout();
     if (Input::get('q')) {
         $polls = Poll::where('title', 'LIKE', '%' . Input::get('q') . '%')->orderBy('created_at', 'desc')->paginate(20);
     } else {
         $polls = Poll::orderBy('created_at', 'desc')->paginate(20);
     }
     View::share('title', Lang::get('admin.polls'));
     View::share('polls', $polls);
     $this->layout->content = View::make('backend.polls.index');
 }
开发者ID:Puskice,项目名称:PuskiceCMS,代码行数:20,代码来源:PollController.php

示例2: index

 /**
  * Display a listing of the resource.
  * GET /frontend/publicpoll
  *
  * @return Response
  */
 public function index()
 {
     try {
         $polls = Poll::orderBy('id', 'desc')->paginate(5);
         foreach ($polls as $key => $poll) {
             $polls[$key]->vote_count = 1;
             foreach ($poll->pollOptions as $option) {
                 $polls[$key]->vote_count += $option->vote_count;
             }
             if ($polls[$key]->vote_count > 1) {
                 $polls[$key]->vote_count--;
             }
         }
         //$categoryNews = News::inCategory($category->id)->where('published', '=', 2)->where('post_type', '=', 1)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->paginate(5);
         $articles = News::inCategories(Config::get('settings.homepage'))->where('published', '=', 2)->where('post_type', '=', 1)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(10)->get();
         $featured = News::where('published', '=', 2)->where('featured', '=', 1)->where('post_type', '=', 1)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->orderBy('created_at', 'desc')->take(3)->get();
         $results = News::inCategories(Config::get('settings.results'))->distinct('permalink')->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('published', '=', 2)->where('post_type', '=', 1)->groupBy('permalink')->orderBy('news.created_at', 'desc')->take(10)->get();
         $featuredImage = News::inCategories(array(25))->where('published', '=', 2)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(3)->get();
         $didYouKnow = News::inCategories(array(30))->where('published', '=', 2)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(3)->get();
         $magazine = News::inCategories(Config::get('settings.magazine'))->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('published', '=', 2)->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(4)->get();
         $ourComment = News::inCategories(array(17))->where('published', '=', 2)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(4)->get();
         $feed = getFeed('http://bazaznanja.puskice.org/feed/qa.rss', 4);
         $poll = null;
         $poll = Poll::where('published', '=', '1')->where('end_date', '>', date("Y-m-d H:i:s", strtotime('now')))->where('created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->first();
         if (isset($poll->id)) {
             $poll->pollOptions;
         }
         View::share('title', "Анкете | Пушкице");
         $ogimage = Config::get('settings.defaultImage');
         $meta = "\t<meta property='og:image' content='" . $ogimage . "'/>\n\t\t\t\t\t\t<meta property='og:title' content='" . __("Анкете | Пушкице | Тачка спајања студената ФОН-а") . "'/>\n\t\t\t\t\t\t<meta property='fb:app_id' content='355697367892039'/>\n\t\t\t\t\t\t<meta property='og:site_name' content='" . __("Пушкице - ФОН Андерграунд") . "'/>\n\t\t\t\t\t\t<meta property='og:type' content='article'/>\n\t\t\t\t\t\t<meta property='og:url' content='" . _l(Request::root() . "/ankete") . "'/>\n\t\t\t\t\t\t<meta property='og:description' content='" . __("Анкете - Пушкице") . "' />\n\t\t\t\t\t\t<meta name='twitter:card' content='summary_large_image'>\n\t\t\t\t\t\t<meta name='twitter:site' content='" . __("Пушкице - ФОН Андерграунд") . "'>\n\t\t\t\t\t\t<meta name='twitter:creator' content='@puskice'>\n\t\t\t\t\t\t<meta name='twitter:domain' content='puskice.org'>\n\t\t\t\t\t\t<meta name='twitter:app:name:iphone' content='" . __("Пушкице") . "'>\n\t\t\t\t\t\t<meta name='twitter:app:name:ipad' content='" . __("Пушкице") . "'>\n\t\t\t\t\t\t<meta name='twitter:title' content='" . __("Анкете | Пушкице") . "'>\n\t\t\t\t\t\t<meta name='twitter:description' content='" . __("Анкете - Пушкице") . "'>\n\t\t\t\t\t\t<meta name='twitter:image' content='" . $ogimage . "'>";
         $data = array('articles' => $articles, 'featured' => $featured, 'results' => $results, 'ourComment' => $ourComment, 'magazine' => $magazine, 'featuredImage' => $featuredImage, 'didYouKnow' => $didYouKnow, 'feed' => $feed, 'poll' => $poll, 'meta' => $meta, 'polls' => $polls);
         $this->setLayout($data);
         $this->layout->center = View::make('frontend.content.polls', $data);
     } catch (Exception $e) {
         return App::abort(404);
     }
 }
开发者ID:Puskice,项目名称:PuskiceCMS,代码行数:43,代码来源:PublicPollController.php


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