Exemplo n.º 1
0
 public function autocomplete()
 {
     $settlement = (int) Input::get('settlement');
     $name = htmlentities(Input::get('query'), ENT_QUOTES, 'UTF-8', false);
     if (0 >= $settlement || self::MIN_AUTOCOMPLETE_LENGTH > mb_strlen($name)) {
         return ['results' => [], 'more' => false];
     }
     $result = Street::where('city_id', $settlement)->whereNested(function ($query) use($name) {
         $query->where('name', 'LIKE', "%{$name}%")->orWhere('name_en', 'LIKE', "%{$name}%");
     })->get(['id', 'bg' === App::getLocale() ? 'name' : 'name_en AS name']);
     return ['results' => $result, 'more' => false];
 }
Exemplo n.º 2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  * @codeCoverageIgnore
  */
 public function handle()
 {
     $time = time();
     DB::connection('econt')->disableQueryLog();
     $this->comment(PHP_EOL . 'Starting...');
     $this->comment(PHP_EOL . 'Importing zones and settlements... Please wait.');
     Zone::whereRaw(1)->delete();
     Settlement::whereRaw(1)->delete();
     foreach (App::make('Econt')->zones() as $zone) {
         (new Zone())->import($zone);
         $zone_id = Arr::has($zone, 'id') ? Arr::get($zone, 'id') : 0;
         foreach (App::make('Econt')->settlements($zone_id) as $settlement) {
             if (!is_array($settlement)) {
                 continue;
             }
             (new Settlement())->import($settlement);
         }
     }
     $this->comment(PHP_EOL . 'Zones and settlements imported successfully.');
     $this->comment(PHP_EOL . 'Importing regions... Please wait.');
     Region::whereRaw(1)->delete();
     foreach (App::make('Econt')->regions() as $region) {
         (new Region())->import($region);
     }
     $this->comment(PHP_EOL . 'Regions imported successfully.' . PHP_EOL);
     $this->comment(PHP_EOL . 'Importing neighbourhoods... Please wait.');
     Neighbourhood::whereRaw(1)->delete();
     foreach (App::make('Econt')->neighbourhoods() as $region) {
         (new Neighbourhood())->import($region);
     }
     $this->comment(PHP_EOL . 'Neighbourhoods imported successfully.' . PHP_EOL);
     $this->comment(PHP_EOL . 'Importing streets... Please wait.');
     Street::whereRaw(1)->delete();
     foreach (App::make('Econt')->streets() as $region) {
         (new Street())->import($region);
     }
     $this->comment(PHP_EOL . 'Streets imported successfully.' . PHP_EOL);
     $this->comment(PHP_EOL . 'Importing offices... Please wait.');
     Office::whereRaw(1)->delete();
     foreach (App::make('Econt')->offices() as $region) {
         (new Office())->import($region);
     }
     $this->comment(PHP_EOL . 'Offices imported successfully.' . PHP_EOL);
     $this->comment(PHP_EOL . sprintf('Finished in %f minutes.', (time() - $time) / 60));
 }
Exemplo n.º 3
0
 protected function _receiver()
 {
     $settlement = Settlement::find((int) Input::get('receiver.settlement'));
     $receiver = new Receiver();
     $receiver->name = Input::get('receiver.name');
     $receiver->city = $settlement->name;
     $receiver->post_code = $settlement->post_code;
     $receiver->phone_num = Input::get('receiver.phone');
     switch (Input::get('receiver.pickup')) {
         case 'address':
             $receiver->street = Street::find((int) Input::get('receiver.street'))->name;
             $receiver->street_num = Input::get('receiver.street_num');
             $receiver->street_vh = Input::get('receiver.street_vh');
             $receiver->street_et = Input::get('receiver.street_et');
             $receiver->street_ap = Input::get('receiver.street_ap');
             $receiver->street_other = Input::get('receiver.street_other');
             break;
         case 'office':
             $receiver->office_code = Office::find((int) Input::get('receiver.office'))->code;
             break;
     }
     return $receiver;
 }