/** * 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; } if ($this->city->violation == "0") { return false; } $start_day = strtotime('now 00:00:00'); $end_day = strtotime('now 23:59:00'); $violations = Violations::getUncheckedViolations($this->city->db, $start_day, $end_day); if (!$violations->isEmpty()) { foreach ($violations as $v) { $driver = Driver::getDriverInfoByCar($this->city->db, $v->vio_nomer); if (isset($driver->driver_id)) { $this->call('drivers:operations', ['driver' => $driver->driver_id, 'op' => 0, 'summ' => $this->city->violation_price, 'reason' => 'Штраф за превышение скорости', 'time' => time(), 'comment' => $v->vio_text, '--city' => $city]); $v->status = 1; $v->save(); } } } }
public function violation() { $violations = Violations::getUncheckedViolations($this->city->db, $this->start_day, $this->end_day); foreach ($violations as $v) { $driver = Driver::getDriverInfoByCar($this->city->db, $v->vio_nomer); if (isset($driver->driver_id)) { $this->MoneyOperations($driver->driver_id, 1, 0, 'TEST', 'TEST VIOLATION'); $v->status = 1; $v->save(); } } return $violations; }