info($params['gps_imei']); if($car['code'] == 0) self::setError('添加失败'); Vehicle::create([ 'license' => $params['license'], 'gps_imei' => $params['gps_imei'], 'gps_carid' => $car['data']['carId'], 'status' => $params['status'] ]); 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'], 'gps_carid' => $params['gps_carid'], 'status' => $params['status'] ]); 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 delete(array $params): bool { return Vehicle::destroy($params['id']); } /** * @notes 获取详情 * @param $params * @return array * @author likeadmin * @date 2023/08/17 09:23 */ public static function detail($params): array { return Vehicle::findOrEmpty($params['id'])->toArray(); } }