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


PHP Collection::sortByDesc方法代码示例

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


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

示例1: getMyStoreAlert

 /**
  * 点击我的收藏那个加号弹出的对话框
  * 必须登录才能操作
  */
 public function getMyStoreAlert($user_x, $user_y)
 {
     if (!Auth::check()) {
         return;
     } else {
         $user = Auth::user();
     }
     $data = array();
     //$data['new_shop'] = array();
     $data['hot_shop'] = array();
     $geohash = new Geohash();
     $shopArray = $geohash->geohashGet($user_x, $user_y);
     $shops = new Collection();
     foreach ($shopArray['data'] as $oneshop) {
         $onestore = array();
         $shop = $oneshop['shopData'];
         $shops->add($shop);
     }
     /* 取消最新餐厅这儿
     		$new_shops = $shops->sortByDesc('sold_num');
     		foreach($new_shops as $shop){
     			$one = array();
     			$one['shop_id']            = $shop->id;
     			$one['place_id']           = '123';
     			$one['shop_url']           = url('shop/'.$shop->id);
     			$one['shop_logo']          = $shop->pic;
     			$one['deliver_time']       = (float)$shop->interval;
     			$one['deliver_start']      = $shop->operation_time;
     			$one['shop_name']          = $shop->name;
     			$one['shop_type']          = $shop->type;
     			$Level                     = $this->getLevel($shop);
     			$one['shop_level']         = $Level['thing_total'];
     			$one['order_count']        = (float)$shop->sold_num;
     			$one['is_opening']         = $shop->is_online;
     			$one['is_ready_for_order'] = $shop->reserve;
     			if( !Auth::check() ){
     				$one['is_collected'] = false;
     			} else{
     				$user = Auth::user();
     				$one['is_collected'] = in_array($shop->id, $user->collectShop->lists('shop_id'))?true:false;	// 是否被收藏了
     			}
     			array_push($data['new_shop'], $one);
     		}
     		*/
     $hot_shops = $shops->sortByDesc('addtime');
     foreach ($hot_shops as $shop) {
         $one = array();
         $one['shop_id'] = $shop->id;
         $one['place_id'] = '123';
         $one['shop_url'] = url('shop/' . $shop->id);
         $one['shop_logo'] = $shop->pic;
         $one['deliver_time'] = (double) $shop->interval;
         $one['deliver_start'] = $shop->operation_time;
         $one['shop_name'] = $shop->name;
         $one['shop_type'] = $shop->type;
         $Level = $this->getLevel($shop);
         $one['shop_level'] = $Level['thing_total'];
         $one['order_count'] = (double) $shop->sold_num;
         $one['is_opening'] = $this->isOnline($shop->operation_time, date('H:i')) ? 0 : 1;
         $one['is_ready_for_order'] = $shop->reserve;
         $one['is_collected'] = in_array($shop->id, $user->collectShop->lists('shop_id')) ? true : false;
         array_push($data['hot_shop'], $one);
     }
     return $data;
 }
开发者ID:andycall,项目名称:haochigou,代码行数:69,代码来源:MainController.php

示例2: getCollectionMessages

 /**
  *
  * @param MessageIterator|Message[]
  *
  * @return Collection
  */
 public function getCollectionMessages($MessageIterator)
 {
     $messages = new Collection();
     foreach ($MessageIterator as $value) {
         $message = new \stdClass();
         $message->number = $value->getNumber();
         $message->subject = $value->getSubject();
         $message->from = $value->getFrom();
         $message->date = $this->formatdate($value->getDate());
         $message->seen = $value->isSeen();
         $messages->push($message);
     }
     return $messages->sortByDesc('number');
 }
开发者ID:ProyectoSanClemente,项目名称:proyectoapi5.1,代码行数:20,代码来源:EmailController.php

示例3: getMyStoreAlert

 /**
  * 点击我的收藏那个加号弹出的对话框
  */
 public function getMyStoreAlert()
 {
     $data = array();
     $data['new_shop'] = array();
     $data['hot_shop'] = array();
     #TODO:由前端获取用户坐标
     $user_x = 39.9812385;
     $user_y = 116.3068369;
     $geohash = new Geohash();
     $shopArray = $geohash->geohashGet($user_x, $user_y);
     $shops = new Collection();
     foreach ($shopArray['data'] as $oneshop) {
         $onestore = array();
         $shop = $oneshop['shopData'];
         $shops->add($shop);
     }
     $new_shops = $shops->sortByDesc('sold_num');
     foreach ($new_shops as $shop) {
         $one = array();
         $one['shop_id'] = $shop->id;
         #TODO 没有place_id
         $one['place_id'] = '123';
         $one['shop_url'] = 'shop/' . $shop->id;
         $one['shop_logo'] = $shop->pic;
         $one['deliver_time'] = $shop->interval;
         $one['deliver_start'] = $shop->operation_time;
         $one['shop_name'] = $shop->name;
         $one['shop_type'] = $shop->type;
         $Level = $this->getLevel($shop);
         $one['shop_level'] = $Level['thing_total'];
         $one['order_count'] = $shop->sold_num;
         $one['is_opening'] = $shop->is_online;
         $one['is_ready_for_order'] = $shop->reserve;
         if (!Auth::check()) {
             $one['is_collected'] = false;
         } else {
             $user = Auth::user();
             $one['is_collected'] = in_array($shop->id, $user->collectShop->lists('shop_id')) ? true : false;
             // 是否被收藏了
         }
         array_push($data['new_shop'], $one);
     }
     $hot_shops = $shops->sortByDesc('addtime');
     foreach ($hot_shops as $shop) {
         $one = array();
         $one['shop_id'] = $shop->id;
         #TODO 没有place_id
         $one['place_id'] = '123';
         $one['shop_url'] = 'shop/' . $shop->id;
         $one['shop_logo'] = $shop->pic;
         $one['deliver_time'] = $shop->interval;
         $one['deliver_start'] = $shop->operation_time;
         $one['shop_name'] = $shop->name;
         $one['shop_type'] = $shop->type;
         $Level = $this->getLevel($shop);
         $one['shop_level'] = $Level['thing_total'];
         $one['order_count'] = $shop->sold_num;
         $one['is_opening'] = $shop->is_online;
         $one['is_ready_for_order'] = $shop->reserve;
         if (!Auth::check()) {
             $one['is_collected'] = false;
         } else {
             $user = Auth::user();
             $one['is_collected'] = in_array($shop->id, $user->collectShop->lists('shop_id')) ? true : false;
             // 是否被收藏了
         }
         array_push($data['hot_shop'], $one);
     }
     return $data;
 }
开发者ID:uwitec,项目名称:haochigo,代码行数:73,代码来源:MainController.php


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