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


PHP News::orderBy方法代码示例

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


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

示例1: getIndex

 public function getIndex()
 {
     $year = Year::current_year();
     $sponsors = $year->sponsors()->orderBy('sponsor_year.sponsor_level', 'desc')->where('sponsor_year.sponsor_level', '!=', 'Affiliate')->get();
     $news = News::orderBy('updated_at', 'desc')->first();
     return View::make('home.index')->with('news', $news)->with('sponsors', $sponsors);
 }
开发者ID:robinchow,项目名称:rms,代码行数:7,代码来源:HomeController.php

示例2: index

 public function index()
 {
     $advice = \SecurityTip::orderBy(DB::raw("RAND()"))->first();
     $news = \News::orderBy(DB::raw("RAND()"))->first();
     $work = \Work::orderBy(DB::raw("RAND()"))->first();
     return View::make('welcome/index', compact('news', 'work', 'advice'));
 }
开发者ID:Khelek,项目名称:ipsol,代码行数:7,代码来源:WelcomeController.php

示例3: getIndex

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function getIndex()
 {
     if (Session::get('user_level') < Config::get('cms.shopManager')) {
         return Redirect::to(_l(URL::action('AdminHomeController@getIndex')));
     }
     $this->setLayout();
     if (Input::get('q')) {
         $products = Product::where(function ($query) {
             $query->where('title', 'LIKE', '%' . Input::get('q') . '%')->orwhere('long_content', 'LIKE', '%' . Input::get('q') . '%')->orwhere('short_content', 'LIKE', '%' . Input::get('q') . '%');
         })->orderBy('created_at', 'desc')->paginate(20);
     } else {
         $products = News::orderBy('created_at', 'desc')->paginate(20);
     }
     View::share('title', __(Lang::get('shop.products')));
     View::share('products', $products);
     $this->layout->content = View::make('backend.shop.product.index');
 }
开发者ID:Puskice,项目名称:PuskiceCMS,代码行数:22,代码来源:ProductController.php

示例4: getLastNews

 /**
  * @param $limit
  * @return mixed
  */
 public function getLastNews($limit)
 {
     return $this->news->orderBy('created_at', 'desc')->where('lang', $this->getLang())->take($limit)->offset(0)->get();
 }
开发者ID:phillipmadsen,项目名称:app,代码行数:8,代码来源:NewsRepository.php

示例5: getManageNews

 public function getManageNews()
 {
     $query = News::orderBy('id', 'desc')->paginate(10);
     $this->layout->content = View::make('admin.manage_news')->with('news', $query);
 }
开发者ID:hlmasterchief,项目名称:lacrestaurant,代码行数:5,代码来源:AdminController.php

示例6: get_va

 public function get_va()
 {
     //Pull our users VA data
     $record = User::where('cid', '=', Auth::user()->get()->cid)->first();
     //        //Figure out what the last 4 months are and append -1 for the first day of the month
     //        $month = date('Y-m');
     //        $month .= '-1';
     //        $month1before = date('Y-m', strtotime('-1 month'));
     //        $month1before .= '-1';
     //        $month2before = date('Y-m', strtotime('-2 month'));
     //        $month2before .= '-1';
     //        $month3before = date('Y-m', strtotime('-3 month'));
     //        $month3before .= '-1';
     //        //Convert to unix time stamps to compare with the DB
     //        $month = strtotime($month);
     //        $month1before = strtotime($month1before);
     //        $month2before = strtotime($month2before);
     //        $month3before = strtotime($month3before);
     //
     //        //Now let's store our month names in an array
     //        $clicks = array();
     //        $clicks['month_name'] = date("F", $month);
     //        $clicks['month1before_name'] = date("F", $month1before);
     //        $clicks['month2before_name'] = date("F", $month2before);
     //        $clicks['month3before_name'] = date("F", $month3before);
     //
     //
     //        //Count the data in the DB
     //        //Where data is greater than the first of this month and is associated with our logged in user.
     //        $month = Click::where('created_at', '>=', $month)->where('vid', '=', Auth::user()->get()->cid)->count();
     //        //Where data is greater than the first of last month, but less than the first of this month and is associated with our logged in user.
     //        $month1before = Click::where('created_at', '>=', $month1before)->where('created_at', '<', $month)->where('vid', '=', Auth::user()->get()->cid)->count();
     //        //You get the point :)
     //        $month2before = Click::where('created_at', '>=', $month2before)->where('created_at', '<', $month1before)->where('vid', '=', Auth::user()->get()->cid)->count();
     //        $month3before = Click::where('created_at', '>=', $month3before)->where('created_at', '<', $month2before)->where('vid', '=', Auth::user()->get()->cid)->count();
     //        //Add to our clicks array.
     //        $clicks['month'] = $month;
     //        $clicks['month1before'] = $month1before;
     //        $clicks['month2before'] = $month2before;
     //        $clicks['month3before'] = $month3before;
     //Let's just keep it simple for now and get the total number of clicks
     $clicks = Click::where('vid', '=', Auth::user()->get()->cid)->count();
     //Pull our ticket information
     $opentickets = Ticket::where('vid', '=', Auth::user()->get()->cid)->where('status', '=', '1')->orderBy('created_at', 'DESC')->get();
     $openticketscount = count($opentickets);
     $closedtickets = Ticket::where('vid', '=', Auth::user()->get()->cid)->where('status', '=', '0')->orderBy('created_at', 'DESC')->get();
     $closedticketscount = count($closedtickets);
     //Create our array
     $tickets = array();
     $tickets['opentickets'] = $opentickets;
     $tickets['opentickets_count'] = $openticketscount;
     $tickets['closedtickets'] = $closedtickets;
     $tickets['closedtickets_count'] = $closedticketscount;
     //Pull our replies
     $tickets_request = Ticket::where('vid', '=', Auth::user()->get()->cid)->get();
     $tids = array();
     foreach ($tickets_request as $ticket_request) {
         $tid = $ticket_request->id;
         $tids[$tid] = $tid;
     }
     if (!empty($tids)) {
         $replies = TicketReply::whereIn('tid', $tids)->orderBy('created_at', 'ASC')->get();
     } else {
         $replies = '';
     }
     $tickets['replies'] = $replies;
     //Pull our Category data
     $categories = Category::where('hidden', '!=', 1)->get();
     //Check to see if there is a banner if so provide the source for it
     if ($record->banner) {
         $banner = User::getBannerUrl(Auth::user()->get()->cid);
     } else {
         //No banner we will set this as false so the views no not to try and display it.
         $banner = FALSE;
     }
     //Get our news
     $news = News::orderBy("updated_at", "DESC")->get();
     //Create our view with the VA, clicks, categories and tickets data.
     return View::make('va')->with(array('news' => $news, 'record' => $record, 'clicks' => $clicks, 'tickets' => $tickets, 'categories' => $categories, 'banner' => $banner));
 }
开发者ID:A-Lawrence,项目名称:VASOPS,代码行数:80,代码来源:VaController.php

示例7: home

 public function home()
 {
     $news = News::orderBy('id', "DESC")->take(5)->get();
     $this->layout->content = View::make('home')->with("news", $news);
 }
开发者ID:WolfUser,项目名称:UCLoL,代码行数:5,代码来源:ViewController.php

示例8: returnShortCodes

 public static function returnShortCodes()
 {
     $tpl = static::returnTpl();
     shortcode::add("news", function ($params = null) use($tpl) {
         #print_r($params); die;
         if (!Allow::module('news')) {
             return false;
         }
         ## Параметры по-умолчанию
         $default = array('tpl' => Config::get('app-default.news_template', 'default'), 'limit' => Config::get('app-default.news_count_on_page', 3), 'order' => Helper::stringToArray(News::$order_by), 'pagination' => 1, 'type' => false, 'exclude_type' => false, 'include' => false, 'exclude' => false);
         ## Применяем переданные настройки
         $params = $params + $default;
         #dd($params);
         #echo $tpl.$params['tpl'];
         if (empty($params['tpl']) || !View::exists($tpl . $params['tpl'])) {
             throw new Exception('Template [' . $tpl . $params['tpl'] . '] not found.');
         }
         $news = News::orderBy('news.published_at', 'desc')->with('meta.photo', 'meta.gallery.photos', 'meta.seo');
         /*
         ## Получаем новости, делаем LEFT JOIN с news_meta, с проверкой языка и тайтла
         $selected_news = News::where('news.publication', 1)
                                 ->leftJoin('news_meta', 'news_meta.news_id', '=', 'news.id')
                                 ->where('news_meta.language', Config::get('app.locale'))
                                 ->where('news_meta.title', '!=', '')
                                 ->select('*', 'news.id AS original_id', 'news.published_at AS created_at')
                                 ->orderBy('news.published_at', 'desc');
         
         #$selected_news = $selected_news->where('news_meta.wtitle', '!=', '');
         
         ## Получаем новости с учетом пагинации
         #echo $selected_news->toSql(); die;
         #var_dump($params['limit']);
         $news = $selected_news->paginate($params['limit']); ## news list with pagination
         #$news = $selected_news->get(); ## all news, without pagination
         */
         /**
          * Показываем новости только определенных типов
          */
         if (@$params['type']) {
             $params['types'] = (array) explode(',', $params['type']);
             #Helper::d($params);
             if (isset($params['types']) && is_array($params['types']) && count($params['types']) && Allow::module('dictionaries') && class_exists('DicVal')) {
                 $types = DicVal::whereIn('slug', $params['types'])->get();
                 #Helper::tad($types);
                 if ($types->count()) {
                     $types = $types->lists('id');
                     #Helper::tad($types);
                     if (count($types)) {
                         $news = $news->whereIn('type_id', $types);
                     }
                 }
             }
         }
         /**
          * Исключаем новости определенных типов
          */
         if (@$params['exclude_type']) {
             $params['exclude_types'] = (array) explode(',', $params['exclude_type']);
             #Helper::d($params);
             if (isset($params['exclude_types']) && is_array($params['exclude_types']) && count($params['exclude_types']) && Allow::module('dictionaries') && class_exists('DicVal')) {
                 $types = DicVal::whereIn('slug', $params['exclude_types'])->get();
                 #Helper::tad($types);
                 if ($types->count()) {
                     $types = $types->lists('id');
                     #Helper::tad($types);
                     if (count($types)) {
                         $news = $news->whereNotIn('type_id', $types);
                     }
                 }
             }
         }
         /**
          * Будем выводить только новости, ID которых указаны
          */
         if (@$params['include']) {
             $params['includes'] = (array) explode(',', $params['include']);
             if (isset($params['includes']) && is_array($params['includes']) && count($params['includes'])) {
                 $news = $news->whereIn('id', $params['includes']);
             }
         }
         /**
          * Исключаем новости с заданными ID
          */
         if (@$params['exclude']) {
             $params['excludes'] = (array) explode(',', $params['exclude']);
             if (isset($params['excludes']) && is_array($params['excludes']) && count($params['excludes'])) {
                 $news = $news->whereNotIn('id', $params['excludes']);
             }
         }
         $news = $news->paginate($params['limit']);
         #Helper::tad($news);
         /*
         foreach ($news as $n => $new) {
             #print_r($new); die;
             $gall = Rel_mod_gallery::where('module', 'news')->where('unit_id', $new->original_id)->first();
             #foreach ($gall->photos as $photo) {
             #	print_r($photo->path());
             #}
             #print_r($gall->photos); die;
             $new->gall = @$gall;
//.........这里部分代码省略.........
开发者ID:Grapheme,项目名称:amway,代码行数:101,代码来源:public_news.controller.php

示例9: siteMap_xml

 public function siteMap_xml()
 {
     try {
         $page = Pages::where("_name", "=", "sitemap")->get()->first();
         $pages = Pages::where('_dependsOn', "=", NULL)->where("_public", "=", "1")->orderBy('_priority', 'DESC')->get();
         $news = News::orderBy('_date', 'DESC')->get();
     } catch (Exception $e) {
         App::abort(500);
     }
     $header = '<?xml version="1.0" encoding="UTF-8"?>';
     // Renvoi de la vue avec les news et l'en-tête :
     $page = $this->layout->content = View::make('pages.sitemap.sitemap_xml', array("news" => $news, "pages" => $pages, "header" => $header));
     return Response::make($page, '200')->header('Content-Type', 'text/xml');
 }
开发者ID:Benoit-ROBIN,项目名称:u-hochiminh,代码行数:14,代码来源:MessageController.php

示例10: get_news

 public function get_news()
 {
     $news = News::orderBy("updated_at", "DESC")->get();
     return View::make('console.news')->with(array("news" => $news));
 }
开发者ID:A-Lawrence,项目名称:VASOPS,代码行数:5,代码来源:ConsoleController.php


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