'boolean', 'distance' => 'float', 'limit_speed' => 'float', 'alert_speed' => 'float', 'outlaw_speed' => 'float', 'limit_time' => 'float', 'diff' => 'float', 'mergedone' => 'boolean', 'faildata' => 'boolean', 'processcheck' => 'integer', 'postcheck' => 'integer', 'unreportmergedone' => 'integer' ]; // append fields protected $appends = [ 'law_type', ]; public function violationlaw() { return $this->hasOne(ViolationLaw::class, 'violationcode', 'violationcode'); } public function getLawTypeAttribute() { // 取得陣列 $violationtype = "區間超速"; // $violationtype = []; if ($violationtype == "未依標誌標線號誌" || $violationtype == "未依標誌標線行駛" || $violationtype == "機車未依規定兩段式左轉") { $violationtype = ["未依標誌標線號誌行駛"]; } else if ($violationtype == "闖紅燈") { $violationtype = ["闖紅燈", "紅燈右轉", "紅燈越線"]; } else if ($violationtype == "未禮讓行人") { $violationtype = ["未禮讓行人"]; } else if ($violationtype == "違規停車") { $violationtype = ["違規停車"]; } else if ($violationtype == "未保持路口淨空") { $violationtype = ["未保持路口淨空"]; } else if ($violationtype == "超速") { $violationtype = ["超速"]; } else { $violationtype = [$violationtype]; } $except_arr =[ '3310146', '3310148', '4340069' ]; $types = ViolationLaw::whereIn('type', $violationtype)->whereNotIn('violationcode',$except_arr)->get(); $lawData = []; foreach ($types as $type) { $lawData["$type->violationcode"] = "[$type->violationcode] $type->display_name"; } $customLaws = ViolationLaw::whereIn('violationcode', ['72000041', '72000051', '72000061'])->get(); foreach ($customLaws as $type) { $lawData["$type->violationcode"] = "[$type->violationcode] $type->display_name"; } return $lawData; } // public function getMergePictureAttribute($value) // { // // replace * with / // return 'ParsingFiles/Interval/' . str_replace('*', '/', $value); // } // public function getStartPictureAttribute($value) // { // return $value ? asset('storage/' . $value) : null; // } // public function getEndPictureAttribute($value) // { // return $value ? asset('storage/' . $value) : null; // } // public function getStartVideoAttribute($value) // { // return $value ? asset('storage/' . $value) : null; // } // public function getEndVideoAttribute($value) // { // return $value ? asset('storage/' . $value) : null; // } // public function getUnreportPictureAttribute($value) // { // return $value ? asset('storage/' . $value) : null; // } // public function getMergePictureAttribute($value) // { // return $value ? asset('storage/' . $value) : null; // } // public function getCreatedAtAttribute($value) // { // return $value ? date('Y-m-d H:i:s', strtotime($value)) : null; // } // public function getUpdatedAtAttribute($value) // { // return $value ? date('Y-m-d H:i:s', strtotime($value)) : null; // } // public function getDeletedAtAttribute($value) // { // return $value ? date('Y-m-d H:i:s', strtotime($value)) : null; // } }