Esempio n. 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire(Almaty $almaty, Astana $astana)
 {
     $city = $this->option('city');
     if ($city == 1) {
         $this->city = $almaty;
     } else {
         $this->city = $astana;
     }
     $tm = new TMBase($this->city);
     $crews = $tm->get_all_crews();
     $collection = Collection::make();
     DB::beginTransaction();
     if (!empty($crews)) {
         DB::connection($this->city->db)->table('crews')->truncate();
         foreach ($crews as $v) {
             $insertion = ['id' => isset($v->crew_id) ? $v->crew_id : 0, 'code' => isset($v->code) ? $v->code : 0, 'car' => isset($v->car_id) ? $v->car_id : NULL, 'driver' => isset($v->driver_id) ? $v->driver_id : NULL, 'uptime' => time(), 'deleted' => 0];
             $collection->push($insertion);
         }
         DB::connection($this->city->db)->table('crews')->insert($collection->toArray());
     }
     DB::commit();
 }
Esempio n. 2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire(Almaty $almaty, Astana $astana)
 {
     $city = $this->option('city');
     if ($city == 1) {
         $this->city = $almaty;
     } else {
         $this->city = $astana;
     }
     $tm = new TMBase($this->city);
     $crews = $tm->get_all_crews();
     $collection = Collection::make();
     DB::beginTransaction();
     if (!empty($crews)) {
         DB::connection($this->city->db)->table('crews_info')->truncate();
         foreach ($crews as $v) {
             $insertion = ['crew_id' => empty($v->crew_id) ? 'NULL' : $v->crew_id, 'code' => empty($v->code) ? 'NULL' : $v->code, 'name' => empty($v->name) ? 'NULL' : $v->name, 'driver_id' => empty($v->driver_id) ? 'NULL' : $v->driver_id, 'car_id' => empty($v->car_id) ? 'NULL' : $v->car_id, 'shashka' => empty($v->car_id) ? 'NULL' : $v->has_light_house, 'updated' => date('Y-m-d H:i:s', time())];
             $collection->push($insertion);
         }
         DB::connection($this->city->db)->table('crews_info')->insert($collection->toArray());
     }
     DB::commit();
 }