添加基地排序
parent
39d50c3acc
commit
135218ff54
|
|
@ -29,6 +29,7 @@ class AgriculturalBaseRequest extends FormRequest
|
||||||
'address_lat' => 'nullable|regex:/^\d+(\.\d{1,10})?$/',
|
'address_lat' => 'nullable|regex:/^\d+(\.\d{1,10})?$/',
|
||||||
'address_lng' => 'nullable|regex:/^\d+(\.\d{1,10})?$/',
|
'address_lng' => 'nullable|regex:/^\d+(\.\d{1,10})?$/',
|
||||||
'parent_id' => 'required_if:type,1|integer|min:0',
|
'parent_id' => 'required_if:type,1|integer|min:0',
|
||||||
|
'sort' => 'nullable|integer|min:0',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ class AgriculturalBase extends Model
|
||||||
'name', 'person', 'address', 'address_lat', 'address_lng',
|
'name', 'person', 'address', 'address_lat', 'address_lng',
|
||||||
'description', 'map', 'areas', 'workforce',
|
'description', 'map', 'areas', 'workforce',
|
||||||
'parent_id', 'cultivated',
|
'parent_id', 'cultivated',
|
||||||
|
'sort',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function parent(){
|
public function parent(){
|
||||||
|
|
@ -38,7 +39,7 @@ class AgriculturalBase extends Model
|
||||||
|
|
||||||
public function scopeSort($q)
|
public function scopeSort($q)
|
||||||
{
|
{
|
||||||
return $q->orderBy('created_at', 'desc');
|
return $q->orderBy('sort', 'desc')->orderBy('created_at', 'desc');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function crops()
|
public function crops()
|
||||||
|
|
|
||||||
|
|
@ -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('agricultural_bases', function (Blueprint $table) {
|
||||||
|
//
|
||||||
|
$table->unsignedInteger('sort')->default(0)->comment('排序');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('agricultural_bases', function (Blueprint $table) {
|
||||||
|
//
|
||||||
|
$table->dropColumn(['sort']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue