erp-backend/database/seeders/SystemConfigSeeder.php
2026-04-01 17:07:04 +08:00

58 lines
2.5 KiB
PHP

<?php
namespace Database\Seeders;
use App\Models\SystemConfig;
use Illuminate\Database\Seeder;
class SystemConfigSeeder extends Seeder
{
public function run(): void
{
// 微信配置组
$this->createConfig('wechat', 'enabled', 'false', 'switch', '启用微信');
$this->createConfig('wechat', 'app_id', '', 'text', 'AppID');
$this->createConfig('wechat', 'app_secret', '', 'password', 'AppSecret');
$this->createConfig('wechat', 'token', '', 'text', 'Token');
$this->createConfig('wechat', 'encoding_aes_key', '', 'text', 'EncodingAESKey');
// 短信配置组
$this->createConfig('sms', 'enabled', 'false', 'switch', '启用短信');
$this->createConfig('sms', 'access_key_id', '', 'text', 'AccessKey ID');
$this->createConfig('sms', 'access_key_secret', '', 'password', 'AccessKey Secret');
$this->createConfig('sms', 'sign_name', '', 'text', '短信签名');
$this->createConfig('sms', 'template_codes', '{}', 'text', '模板代码');
// 邮件配置组
$this->createConfig('mail', 'enabled', 'false', 'switch', '启用邮件');
$this->createConfig('mail', 'driver', 'smtp', 'text', '邮件驱动');
$this->createConfig('mail', 'host', '', 'text', 'SMTP服务器');
$this->createConfig('mail', 'port', '465', 'number', '端口');
$this->createConfig('mail', 'encryption', 'ssl', 'text', '加密方式');
$this->createConfig('mail', 'username', '', 'text', '用户名');
$this->createConfig('mail', 'password', '', 'password', '密码');
$this->createConfig('mail', 'from_email', '', 'text', '发件人邮箱');
$this->createConfig('mail', 'from_name', 'ERP系统', 'text', '发件人名称');
// 系统配置组
$this->createConfig('system', 'site_name', 'ERP管理系统', 'text', '站点名称');
$this->createConfig('system', 'site_logo', '', 'image', '站点Logo');
$this->createConfig('system', 'copyright', '© 2026', 'text', '版权信息');
}
private function createConfig(string $group, string $key, string $value, string $type, string $label, ?string $description = null, int $sort = 0): void
{
SystemConfig::updateOrCreate(
['group' => $group, 'key' => $key],
[
'value' => $value,
'type' => $type,
'label' => $label,
'description' => $description,
'sort' => $sort,
'status' => 'active',
]
);
}
}