初始化本地仓库
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* 系统配置种子
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace resource\database\seeds;
|
||||
|
||||
use app\model\system\Config;
|
||||
use core\uuid\Snowflake;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ConfigSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
// 清空表
|
||||
Config::truncate();
|
||||
|
||||
$configs = include base_path('resource/data/config/config.php');
|
||||
|
||||
// 插入配置项
|
||||
foreach ($configs as $config) {
|
||||
Config::create([
|
||||
'id'=>Snowflake::generate(),
|
||||
'group_code' => $config['group_code'] ?? '',
|
||||
'code' => $config['code'] ?? '',
|
||||
'name' => $config['name'] ?? '',
|
||||
'content' => is_array($config['content'] ?? '') ? json_encode($config['content'], JSON_UNESCAPED_UNICODE) : ($config['content'] ?? ''),
|
||||
'is_sys' => $config['is_sys'] ?? 0,
|
||||
'enabled' => $config['enabled'] ?? 1,
|
||||
'created_at' => $config['created_at'] ?? time(),
|
||||
'updated_at' => $config['updated_at'] ?? time(),
|
||||
'deleted_at' => $config['deleted_at'] ?? null,
|
||||
'remark' => $config['remark'] ?? '',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user