添加设备可以排序
parent
09253ca753
commit
438f037bb5
|
|
@ -133,7 +133,7 @@ class AgriculturalBaseController extends Controller
|
||||||
$list = Device::where([
|
$list = Device::where([
|
||||||
'agricultural_base_id' => $agriculturalBasic->id,
|
'agricultural_base_id' => $agriculturalBasic->id,
|
||||||
'type'=>$deviceType
|
'type'=>$deviceType
|
||||||
])->get()->pluck('monitoring_point', 'id')->toArray();
|
])->orderBy('sort', 'desc')->get()->pluck('monitoring_point', 'id')->toArray();
|
||||||
return $this->json($list);
|
return $this->json($list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -196,7 +196,7 @@ class DeviceController extends Controller
|
||||||
$deviceData = Device::where([
|
$deviceData = Device::where([
|
||||||
'agricultural_base_id' => $baseId,
|
'agricultural_base_id' => $baseId,
|
||||||
'type' => $deviceType,
|
'type' => $deviceType,
|
||||||
])->get();
|
])->orderBy('sort', 'desc')->get();
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
switch ($deviceType) {
|
switch ($deviceType) {
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ class DeviceRequest extends FormRequest
|
||||||
'extends.password' => 'required_if:type,1|string',
|
'extends.password' => 'required_if:type,1|string',
|
||||||
'extends.passage' => 'required_if:type,1|string',
|
'extends.passage' => 'required_if:type,1|string',
|
||||||
'is_recommend' => 'filled|boolean',
|
'is_recommend' => 'filled|boolean',
|
||||||
|
'sort' => 'nullable|integer|min:0',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,8 @@ class DeviceResource extends JsonResource
|
||||||
return $this->createdBy?->name;
|
return $this->createdBy?->name;
|
||||||
}, ''), //录入人
|
}, ''), //录入人
|
||||||
'created_at' => strtotime($this->created_at) ?? 0, //录入时间
|
'created_at' => strtotime($this->created_at) ?? 0, //录入时间
|
||||||
'is_recommend' => $this->is_recommend
|
'is_recommend' => $this->is_recommend,
|
||||||
|
'sort' => $this->sort,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ class Device extends Model
|
||||||
'extends',
|
'extends',
|
||||||
'created_by',
|
'created_by',
|
||||||
'updated_by',
|
'updated_by',
|
||||||
|
'sort',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function base()
|
public function base()
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?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->unsignedInteger('sort')->nullable()->default(0)->comment('排序');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('devices', function (Blueprint $table) {
|
||||||
|
//
|
||||||
|
$table->dropColumn(['sort']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue