$params['license'], 'gps_imei' => $params['gps_imei'], 'type' => 0, 'status' => 0, ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 编辑 * @param array $params * @return bool * @author likeadmin * @date 2023/08/17 09:23 */ public static function edit(array $params): bool { Db::startTrans(); try { Vehicle::where('id', $params['id'])->update([ 'license' => $params['license'], 'gps_imei' => $params['gps_imei'], 'type' => $params['type'], 'status' => $params['status'], ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 获取详情 * @param $params * @return array * @author likeadmin * @date 2023/08/17 09:23 */ public static function detail($params): array { $data = Vehicle::findOrEmpty($params['id']); $data['mileage'] = 0; if($data['status'] == 2){ //获取租赁信息 $data['rent_info'] = VehicleRent::where('car_id',$data['id'])->find(); } return $data->toArray(); } }