public function index($buyerId = null)
 {
     if (is_null($buyerId)) {
         return BuyerAddress::all();
     } else {
         return BuyerAddress::where('buyer_id', $buyerId)->get();
     }
 }
示例#2
0
 /**
  * 收货地址列表
  * @return string
  * @author zhengqian@dajiayao.cc
  */
 public function index()
 {
     $buyerId = $this->buyerId;
     $buyerAddress = BuyerAddress::where("buyer_id", $buyerId)->get();
     $arrRet = array();
     foreach ($buyerAddress as $k => $addr) {
         $county = $addr->addresses;
         $city = $county->getFather();
         $province = $city->getFather();
         $arrRet[$k]['id'] = $addr->id;
         $arrRet[$k]['provinceId'] = $province->id;
         $arrRet[$k]['province'] = $province->address;
         $arrRet[$k]['cityId'] = $city->id;
         $arrRet[$k]['city'] = $city->address;
         $arrRet[$k]['countyId'] = $county->id;
         $arrRet[$k]['county'] = $county->address;
         $arrRet[$k]['address'] = $addr->address;
         $arrRet[$k]['postcode'] = $addr->postcode;
         $arrRet[$k]['receiver'] = $addr->receiver;
         $arrRet[$k]['mobile'] = $addr->mobile;
         $arrRet[$k]['default'] = $addr->default == 1 ? true : false;
     }
     return RestHelp::success(['addresses' => $arrRet]);
 }