Compare commits

...

2 Commits

Author SHA1 Message Date
vine_liutk 135218ff54 添加基地排序 2023-01-04 15:41:28 +08:00
vine_liutk 39d50c3acc 添加部分数据 2022-12-09 16:34:01 +08:00
5 changed files with 54 additions and 1 deletions

View File

@ -1,3 +1,13 @@
# lcly-data-admin
隆昌农业大数据
php artisan k:g
php artisan admin:install
php artisan db:seed AdminSeeder
php artisan db:seed PermissionSeeder
php artisan db:seed AgriculturalBaseSeeder
php artisan db:seed CropSeeder

View File

@ -29,6 +29,7 @@ class AgriculturalBaseRequest extends FormRequest
'address_lat' => 'nullable|regex:/^\d+(\.\d{1,10})?$/',
'address_lng' => 'nullable|regex:/^\d+(\.\d{1,10})?$/',
'parent_id' => 'required_if:type,1|integer|min:0',
'sort' => 'nullable|integer|min:0',
];
}

View File

@ -20,6 +20,7 @@ class AgriculturalBase extends Model
'name', 'person', 'address', 'address_lat', 'address_lng',
'description', 'map', 'areas', 'workforce',
'parent_id', 'cultivated',
'sort',
];
public function parent(){
@ -38,7 +39,7 @@ class AgriculturalBase extends Model
public function scopeSort($q)
{
return $q->orderBy('created_at', 'desc');
return $q->orderBy('sort', 'desc')->orderBy('created_at', 'desc');
}
public function crops()

View File

@ -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']);
});
}
};

View File

@ -143,6 +143,13 @@ class CropSeeder extends Seeder
['name'=>'不知火','category_id' => 2, 'crop_type' => 1, 'unit' => '吨'],
['name'=>'耙耙柑','category_id' => 2, 'crop_type' => 1, 'unit' => '吨'],
['name'=>'爱媛','category_id' => 2, 'crop_type' => 1, 'unit' => '吨'],
['name'=>'稻虾','category_id' => 3, 'crop_type' => 1, 'unit' => '吨'],
['name'=>'生猪','category_id' => 4, 'crop_type' => 1, 'unit' => '吨'],
['name'=>'水稻','category_id' => 2, 'crop_type' => 1, 'unit' => '吨'],
['name'=>'活草鱼','category_id' => 3, 'crop_type' => 1, 'unit' => '吨'],
['name'=>'鲈鱼','category_id' => 3, 'crop_type' => 1, 'unit' => '吨'],
['name'=>'乌鱼','category_id' => 3, 'crop_type' => 1, 'unit' => '吨'],
['name'=>'鱼类','category_id' => 3, 'crop_type' => 1, 'unit' => '吨'],
];
DB::table('crops')->truncate();
try {