/** * 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(); } } } }
private function endUpdate($start_day) { $date = date('Y-m-d H:i:s', $start_day); \App\Models\Violations::on($this->city->db)->where('status', '=', '1')->where('updated', '<', $date)->delete(); }
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; }
public static function getUncheckedViolations($db, $begin_of_day, $end_of_day) { return Violations::on($db)->where('status', '=', '0')->whereBetween('vio_date', [$begin_of_day, $end_of_day])->get(); }