diff --git a/app/Models/WaterQualityMonitoringLog.php b/app/Models/WaterQualityMonitoringLog.php new file mode 100644 index 0000000..953000d --- /dev/null +++ b/app/Models/WaterQualityMonitoringLog.php @@ -0,0 +1,27 @@ + 'datetime', + ]; + + protected $fillable = [ + 'device_id', + 'agricultural_base_id', + 'chlorine', + 'conductivity', + 'oxygen', + 'ph', + 'temperature', + 'turbidity', + 'monitored_at', + ]; +} diff --git a/database/migrations/2022_10_19_102446_create_water_quality_monitoring_logs_table.php b/database/migrations/2022_10_19_102446_create_water_quality_monitoring_logs_table.php new file mode 100644 index 0000000..928cee4 --- /dev/null +++ b/database/migrations/2022_10_19_102446_create_water_quality_monitoring_logs_table.php @@ -0,0 +1,44 @@ +id(); + $table->unsignedBigInteger('device_id')->comment('设备ID'); + $table->unsignedBigInteger('agricultural_base_id')->comment('农业基地ID'); + $table->decimal('chlorine', 8, 2)->nullable()->comment('余氯 (单位: mg/L)'); + $table->decimal('conductivity', 8, 2)->nullable()->comment('电导率 (单位: us/cm)'); + $table->decimal('oxygen', 8, 2)->nullable()->comment('溶解氧 (单位: mg/L)'); + $table->decimal('ph', 8, 2)->nullable()->comment('PH'); + $table->decimal('temperature', 8, 2)->nullable()->comment('温度 (单位: ℃)'); + $table->decimal('turbidity', 8, 2)->nullable()->comment('浊度 (单位: NTU)'); + $table->timestamp('monitored_at')->comment('监控时间(小时)'); + $table->timestamps(); + + $table->index('device_id'); + $table->index('agricultural_base_id'); + $table->unique('monitored_at'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('water_quality_monitoring_logs'); + } +};