feat: 国家seeder
This commit is contained in:
30
database/seeds/SysCountryInit.php
Normal file
30
database/seeds/SysCountryInit.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use think\migration\Seeder;
|
||||||
|
|
||||||
|
class SysCountryInit extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run Method.
|
||||||
|
*
|
||||||
|
* Write your database seeder using this method.
|
||||||
|
*
|
||||||
|
* More information on writing seeders is available here:
|
||||||
|
* http://docs.phinx.org/en/latest/seeding.html
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
["id" => 1, "name" => "中国", "en_name" => "China", "code" => "ZH", "icon" => null, "status" => 1, "sort" => 1, "created_at" => "2025-01-04 14:04:27", "updated_at" => "2025-03-14 11:52:17"],
|
||||||
|
["id" => 2, "name" => "美国", "en_name" => "USA", "code" => "US", "icon" => null, "status" => 1, "sort" => 2, "created_at" => "2025-03-25 13:45:51", "updated_at" => "2025-04-07 11:54:43"]
|
||||||
|
];
|
||||||
|
|
||||||
|
$table = $this->table('sys_country');
|
||||||
|
|
||||||
|
// empty the table
|
||||||
|
$table->truncate();
|
||||||
|
|
||||||
|
// insert data
|
||||||
|
$table->insert($data)->saveData();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user