设备厂商
parent
606b688163
commit
e2b7bdc6e6
|
|
@ -8,6 +8,7 @@ enum DeviceType: int
|
|||
case Soil = 2; // 土壤设备
|
||||
case WaterQuality = 3; // 水质设备
|
||||
case Meteorological = 4; // 气象设备
|
||||
case Insect = 5; // 虫情设备
|
||||
|
||||
/**
|
||||
* @return string
|
||||
|
|
@ -27,6 +28,7 @@ enum DeviceType: int
|
|||
static::Soil->value => '土壤设备',
|
||||
static::WaterQuality->value => '水质设备',
|
||||
static::Meteorological->value => '气象设备',
|
||||
static::Insect->value => '虫情设备',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ class DeviceRequest extends FormRequest
|
|||
'agricultural_base_id' => 'required|integer|min:0',
|
||||
'sn' => 'required|string|max:64',
|
||||
'monitoring_point' => 'required|string|max:100',
|
||||
'supplier_key' => 'required',
|
||||
'extends' => 'required_if:type,1',
|
||||
'extends.ip' => 'required_if:type,1|string',
|
||||
'extends.port' => 'required_if:type,1|string',
|
||||
|
|
@ -34,6 +35,13 @@ class DeviceRequest extends FormRequest
|
|||
];
|
||||
}
|
||||
|
||||
public function attributes()
|
||||
{
|
||||
return [
|
||||
'supplier_key' => '设备厂商',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
$messages = [
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
use Dcat\Admin\Traits\HasDateTimeFormatter;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Peidikeji\Keywords\Models\Keywords;
|
||||
|
||||
class Device extends Model
|
||||
{
|
||||
|
|
@ -37,6 +38,7 @@ class Device extends Model
|
|||
'created_by',
|
||||
'updated_by',
|
||||
'sort',
|
||||
'supplier',
|
||||
];
|
||||
|
||||
public function base()
|
||||
|
|
@ -53,4 +55,9 @@ class Device extends Model
|
|||
{
|
||||
return $this->belongsTo(AdminUser::class, 'updated_by');
|
||||
}
|
||||
|
||||
public function supplier(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Keywords::class, 'supplier_key', 'key');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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('devices', function (Blueprint $table) {
|
||||
$table->string('supplier_key')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('devices', function (Blueprint $table) {
|
||||
$table->dropColumn(['supplier_key']);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -32,6 +32,16 @@ class KeywordsTableSeeder extends Seeder
|
|||
['key' => 'crops-cate-lingye', 'name' => '林业', 'type_key' => 'crops-category', 'value' => ''],
|
||||
['key' => 'crops-cate-activity', 'name' => '其他', 'type_key' => 'crops-category', 'value' => ''],
|
||||
]],
|
||||
[
|
||||
'key' => 'equipment_supplier',
|
||||
'name' => '设备供应商',
|
||||
'value' => '',
|
||||
'list' => [
|
||||
['key' => 'linkos', 'name' => '慧联无限', 'value' => ''],
|
||||
['key' => 'biang', 'name' => '比昂', 'value' => ''],
|
||||
['key' => 'other', 'name' => '其它', 'value' => ''],
|
||||
],
|
||||
]
|
||||
];
|
||||
|
||||
$list[] = value(function () {
|
||||
|
|
|
|||
Loading…
Reference in New Issue