Compare commits

...

2 Commits

Author SHA1 Message Date
Jing Li 8247f78cf4 Fix 2022-11-24 13:07:40 +08:00
Jing Li 0b4f1394af Update 2022-11-24 13:07:40 +08:00
6 changed files with 84 additions and 0 deletions

View File

@ -74,6 +74,10 @@ class SoilMonitoringLogFixCommand extends Command
} }
} }
if ($log->isDirty()) {
$log->is_filled = true;
}
$log->save(); $log->save();
if ($log->wasChanged()) { if ($log->wasChanged()) {

View File

@ -74,6 +74,10 @@ class WaterQualityMonitoringLogFixCommand extends Command
} }
} }
if ($log->isDirty()) {
$log->is_filled = true;
}
$log->save(); $log->save();
if ($log->wasChanged()) { if ($log->wasChanged()) {

View File

@ -9,8 +9,13 @@ class SoilMonitoringLog extends Model
{ {
use HasFactory; use HasFactory;
protected $attributes = [
'is_filled' => false,
];
protected $casts = [ protected $casts = [
'monitored_at' => 'datetime', 'monitored_at' => 'datetime',
'is_filled' => 'bool',
]; ];
protected $fillable = [ protected $fillable = [
@ -23,5 +28,6 @@ class SoilMonitoringLog extends Model
'p', 'p',
'k', 'k',
'monitored_at', 'monitored_at',
'is_filled',
]; ];
} }

View File

@ -9,8 +9,13 @@ class WaterQualityMonitoringLog extends Model
{ {
use HasFactory; use HasFactory;
protected $attributes = [
'is_filled' => false,
];
protected $casts = [ protected $casts = [
'monitored_at' => 'datetime', 'monitored_at' => 'datetime',
'is_filled' => 'bool',
]; ];
protected $fillable = [ protected $fillable = [
@ -23,5 +28,6 @@ class WaterQualityMonitoringLog extends Model
'temperature', 'temperature',
'turbidity', 'turbidity',
'monitored_at', 'monitored_at',
'is_filled',
]; ];
} }

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('soil_monitoring_logs', function (Blueprint $table) {
$table->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']);
});
}
};

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('water_quality_monitoring_logs', function (Blueprint $table) {
$table->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']);
});
}
};