From 0b4f1394afef9afc8473e5f50a42e65d410f8cd6 Mon Sep 17 00:00:00 2001 From: Jing Li Date: Thu, 24 Nov 2022 13:06:23 +0800 Subject: [PATCH] Update --- .../Commands/SoilMonitoringLogFixCommand.php | 4 +++ .../WaterQualityMonitoringLogFixCommand.php | 4 +++ app/Models/MeteorologicalMonitoringLog.php | 5 +++ app/Models/SoilMonitoringLog.php | 6 ++++ ...s_filled_to_soil_monitoring_logs_table.php | 32 +++++++++++++++++++ ...to_water_quality_monitoring_logs_table.php | 32 +++++++++++++++++++ 6 files changed, 83 insertions(+) create mode 100644 database/migrations/2022_11_24_130241_add_is_filled_to_soil_monitoring_logs_table.php create mode 100644 database/migrations/2022_11_24_130534_add_is_filled_to_water_quality_monitoring_logs_table.php diff --git a/app/Console/Commands/SoilMonitoringLogFixCommand.php b/app/Console/Commands/SoilMonitoringLogFixCommand.php index 2c91ff5..d82fce2 100644 --- a/app/Console/Commands/SoilMonitoringLogFixCommand.php +++ b/app/Console/Commands/SoilMonitoringLogFixCommand.php @@ -74,6 +74,10 @@ class SoilMonitoringLogFixCommand extends Command } } + if ($log->isDirty()) { + $log->is_filled = true; + } + $log->save(); if ($log->wasChanged()) { diff --git a/app/Console/Commands/WaterQualityMonitoringLogFixCommand.php b/app/Console/Commands/WaterQualityMonitoringLogFixCommand.php index 5dc94b1..4929839 100644 --- a/app/Console/Commands/WaterQualityMonitoringLogFixCommand.php +++ b/app/Console/Commands/WaterQualityMonitoringLogFixCommand.php @@ -74,6 +74,10 @@ class WaterQualityMonitoringLogFixCommand extends Command } } + if ($log->isDirty()) { + $log->is_filled = true; + } + $log->save(); if ($log->wasChanged()) { diff --git a/app/Models/MeteorologicalMonitoringLog.php b/app/Models/MeteorologicalMonitoringLog.php index 620bd88..0d0dd18 100644 --- a/app/Models/MeteorologicalMonitoringLog.php +++ b/app/Models/MeteorologicalMonitoringLog.php @@ -10,9 +10,14 @@ class MeteorologicalMonitoringLog extends Model { use HasFactory; + protected $attributes = [ + 'is_filled' => false, + ]; + protected $casts = [ 'wind_direction' => WindDirection::class, 'monitored_at' => 'datetime', + 'is_filled' => 'bool', ]; protected $fillable = [ diff --git a/app/Models/SoilMonitoringLog.php b/app/Models/SoilMonitoringLog.php index 711da7f..d51622e 100644 --- a/app/Models/SoilMonitoringLog.php +++ b/app/Models/SoilMonitoringLog.php @@ -9,8 +9,13 @@ class SoilMonitoringLog extends Model { use HasFactory; + protected $attributes = [ + 'is_filled' => false, + ]; + protected $casts = [ 'monitored_at' => 'datetime', + 'is_filled' => 'bool', ]; protected $fillable = [ @@ -23,5 +28,6 @@ class SoilMonitoringLog extends Model 'p', 'k', 'monitored_at', + 'is_filled', ]; } diff --git a/database/migrations/2022_11_24_130241_add_is_filled_to_soil_monitoring_logs_table.php b/database/migrations/2022_11_24_130241_add_is_filled_to_soil_monitoring_logs_table.php new file mode 100644 index 0000000..f71ef42 --- /dev/null +++ b/database/migrations/2022_11_24_130241_add_is_filled_to_soil_monitoring_logs_table.php @@ -0,0 +1,32 @@ +boolean('is_filled')->default(false)->comment('是否是填充数据'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('soil_monitoring_logs', function (Blueprint $table) { + $table->dropColumn(['is_filled']); + }); + } +}; diff --git a/database/migrations/2022_11_24_130534_add_is_filled_to_water_quality_monitoring_logs_table.php b/database/migrations/2022_11_24_130534_add_is_filled_to_water_quality_monitoring_logs_table.php new file mode 100644 index 0000000..5cdead1 --- /dev/null +++ b/database/migrations/2022_11_24_130534_add_is_filled_to_water_quality_monitoring_logs_table.php @@ -0,0 +1,32 @@ +boolean('is_filled')->default(false)->comment('是否是填充数据'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('water_quality_monitoring_logs', function (Blueprint $table) { + $table->dropColumn(['is_filled']); + }); + } +};