Example #1
0
 public function cityzone($city_id, $reseller, $zonereseller_id, $distance)
 {
     $city = Model::City()->find($city_id);
     if ($city) {
         $tab = $city->assoc();
         $tab['distance'] = ['km' => 0, 'miles' => 0];
         $near = [$tab];
         $near = array_merge($near, getNearCitiesFromZip($city->zip, $distance));
         foreach ($near as $c) {
             $cz = Model::Cityzone()->create(['zonereseller_id' => (int) $zonereseller_id, 'reseller_id' => (int) $reseller, 'zip' => (string) $c['zip'], 'city_id' => (int) $c['id'], 'distance' => (double) $c['distance']['km']])->save();
         }
     }
 }
Example #2
0
 public function getResellersByCustomZip($zip)
 {
     $collection = [];
     $customCities = Model::Cityzone()->where(['zip', '=', (string) $zip])->exec();
     if (!empty($customCities)) {
         foreach ($customCities as $customCity) {
             $resellerId = isAke($customCity, 'reseller_id', false);
             if (false !== $resellerId) {
                 $reseller = Model::Reseller()->find($resellerId);
                 if ($reseller) {
                     array_push($collection, $reseller->assoc());
                 }
             }
         }
     }
     return $this->unTuple($collection);
 }