添加设备可以排序
parent
09253ca753
commit
438f037bb5
|
|
@ -133,7 +133,7 @@ class AgriculturalBaseController extends Controller
|
|||
$list = Device::where([
|
||||
'agricultural_base_id' => $agriculturalBasic->id,
|
||||
'type'=>$deviceType
|
||||
])->get()->pluck('monitoring_point', 'id')->toArray();
|
||||
])->orderBy('sort', 'desc')->get()->pluck('monitoring_point', 'id')->toArray();
|
||||
return $this->json($list);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ class DeviceController extends Controller
|
|||
$deviceData = Device::where([
|
||||
'agricultural_base_id' => $baseId,
|
||||
'type' => $deviceType,
|
||||
])->get();
|
||||
])->orderBy('sort', 'desc')->get();
|
||||
|
||||
$data = [];
|
||||
switch ($deviceType) {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ class DeviceRequest extends FormRequest
|
|||
'extends.password' => 'required_if:type,1|string',
|
||||
'extends.passage' => 'required_if:type,1|string',
|
||||
'is_recommend' => 'filled|boolean',
|
||||
'sort' => 'nullable|integer|min:0',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,8 @@ class DeviceResource extends JsonResource
|
|||
return $this->createdBy?->name;
|
||||
}, ''), //录入人
|
||||
'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',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'sort',
|
||||
];
|
||||
|
||||
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