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


PHP Address::getStreet方法代码示例

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


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

示例1: transform

 protected function transform($entity, $type)
 {
     $transformedData = [];
     if ($type == 'user') {
         foreach (User::$transformationData as $k => $v) {
             if (!empty($entity[$v]) && $k == 'publisher') {
                 $transformedData[$k] = $this->transform($entity[$v], 'publisher');
             } else {
                 $transformedData[$k] = !empty($entity[$v]) ? $entity[$v] : '';
             }
         }
         $transformedData['userType'] = User::getTypeString($entity['level']);
         return $transformedData;
     }
     if ($type == 'publisher') {
         foreach (Publisher::$transformationData as $k => $v) {
             if (!empty($entity[$v]) && $k == 'territories') {
                 $transformedData[$k] = $this->transformCollection($entity[$v], 'territory');
             } else {
                 $transformedData[$k] = !empty($entity[$v]) ? $entity[$v] : '';
             }
         }
         return $transformedData;
     }
     if ($type == 'territory') {
         foreach (Territory::$transformationData as $k => $v) {
             if (!empty($entity[$v]) && $k == 'addresses') {
                 $transformedData[$k] = $this->transformCollection($entity[$v], 'address');
                 $transformedData[$k] = $this->sortArrayByObjKeys($transformedData[$k], $keys = []);
             } else {
                 if (!empty($entity[$v]) && $k == 'records') {
                     $transformedData[$k] = $this->transformCollection($entity[$v], 'record');
                 } else {
                     if (!empty($entity[$v]) && $k == 'publisher') {
                         $transformedData[$k] = $this->transform($entity[$v], 'publisher');
                     } else {
                         if (!empty($entity[$v]) && in_array($k, Territory::$intKeys)) {
                             $transformedData[$k] = (int) $entity[$v];
                         } else {
                             $transformedData[$k] = !empty($entity[$v]) ? $entity[$v] : '';
                         }
                     }
                 }
             }
         }
         return $transformedData;
     }
     if ($type == 'address') {
         foreach (Address::$transformationData as $k => $v) {
             if (!empty($entity[$v]) && $k == 'notes') {
                 $transformedData[$k] = $this->transformCollection($entity[$v], 'note');
             } else {
                 if (!empty($entity[$v]) && $k == 'street') {
                     $transformedData[$k] = $this->transform($entity[$v], 'street');
                     // dd($entity[$v]);
                     // dd($transformedData[$k]);
                     if ($transformedData[$k]['isAptBuilding'] == 1) {
                         $transformedData['isApt'] = true;
                         $transformedData['streetId'] = !empty($transformedData[$k]['streetId']) ? $transformedData[$k]['streetId'] : '';
                         $transformedData['building'] = $transformedData[$k]['street'];
                         $transformedData['streetName'] = Address::getStreet($transformedData[$k]['street']);
                     } else {
                         $transformedData['streetId'] = !empty($transformedData[$k]['streetId']) ? $transformedData[$k]['streetId'] : '';
                     }
                     $transformedData['streetName'] = $transformedData[$k]['street'];
                 } else {
                     $transformedData[$k] = !empty($entity[$v]) ? $entity[$v] : '';
                 }
             }
         }
         // $transformedData['street'] = Address::getStreet($entity['address']);
         // dd($transformedData);
         if ($transformedData['street']['isAptBuilding'] == 1 && strpos(strtolower($transformedData['address']), 'ap') === false) {
             $transformedData['address'] = 'Apt ' . $transformedData['address'];
         }
         $transformedData['address'] = strtoupper($transformedData['address']);
         $transformedData['inActive'] = $transformedData['inActive'] ? 1 : 0;
         return $transformedData;
     }
     if ($type == 'street') {
         foreach (Street::$transformationData as $k => $v) {
             $transformedData[$k] = !empty($entity[$v]) ? $entity[$v] : '';
         }
         // dd($transformedData);
         $transformedData['street'] = strtoupper($transformedData['street']);
         return $transformedData;
     }
     if ($type == 'note') {
         foreach (Note::$transformationData as $k => $v) {
             $transformedData[$k] = !empty($entity[$v]) ? $entity[$v] : '';
         }
         return $transformedData;
     }
     if ($type == 'record') {
         foreach (Record::$transformationData as $k => $v) {
             if (!empty($entity[$v]) && $k == 'territory') {
                 $transformedData[$k] = $this->transform($entity[$v], 'territory');
             } else {
                 if (!empty($entity[$v]) && $k == 'user') {
                     $transformedData[$k] = $this->transform($entity[$v], 'user');
//.........这里部分代码省略.........
开发者ID:pierrestudios,项目名称:territory-api,代码行数:101,代码来源:ApiController.php

示例2: restoreTerritory

 protected static function restoreTerritory($data)
 {
     $territory = Territory::where('number', $data->terrNumber)->first();
     // var_dump($territory['id']); exit;
     if (empty($territory)) {
         $territory = Territory::create(['number' => $data->terrNumber, 'location' => $data->street]);
     }
     // var_dump($territory['id']); exit;
     if (!empty($territory['id'])) {
         $bad = ['STREET', 'COURT', 'PLACE', '(PARTIE SUD)', '(PARTIE NORD)', '(BILDING)', '(BUILDING)'];
         $good = ['ST', 'CT', 'PL', '', '', '', ''];
         foreach ($data->addresses as $i => $add) {
             $streetEntry = str_replace($bad, $good, strtoupper(Address::getStreet($add->address)));
             $street = Street::where('street', $streetEntry)->first();
             // var_dump($street); exit;
             if (empty($street)) {
                 /*
                 				$street = Street::create([
                 					'street' => $streetEntry,
                 					'is_apt_building' => 0
                 				]);
                 */
                 // else
                 var_dump($streetEntry);
             }
             // var_dump($street); exit;
             $addressEntry = strtoupper(trim(str_replace($streetEntry, '', $add->address)));
             $address = Address::where(['address' => $addressEntry, 'street_id' => $street['id']])->first();
             if (empty($address)) {
                 /*
                 				$address = Address::create([
                 					'territory_id' => $territory['id'],
                 					'street_id' => $street['id'],
                 					'address' => $addressEntry,
                 					'name' => $add->name,
                 					'phone' => $add->phone
                 				]);
                 */
                 // else
                 var_dump([$addressEntry, $address]);
             }
             // var_dump($address); exit;
         }
     }
 }
开发者ID:pierrestudios,项目名称:territory-api,代码行数:45,代码来源:PrintController.php


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