Files
star-erp/database/seeders/TenantDatabaseSeeder.php
sky121113 b0848a6bb8 chore: 完善模組化架構遷移與修復前端顯示錯誤
- 修正所有模組 Controller 的 Model 引用路徑 (App\Modules\...)
- 更新 ProductionOrder 與 ProductionOrderItem 模型結構以符合新版邏輯
- 修復 resources/js/utils/format.ts 在處理空值時導致 toLocaleString 崩潰的問題
- 清除全域路徑與 Controller 遷移殘留檔案
2026-01-26 10:37:47 +08:00

43 lines
1.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use App\Modules\Core\Models\User;
use Spatie\Permission\Models\Role;
use Spatie\Permission\Models\Permission;
/**
* 租戶資料庫專用 Seeder
*
* 建立新租戶時會自動執行此 Seeder負責
* 1. 建立預設的超級管理員帳號
* 2. 設定權限與角色
*/
class TenantDatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*/
public function run(): void
{
// 建立預設管理員帳號
$admin = User::firstOrCreate(
['username' => 'admin'],
[
'name' => '系統管理員',
'email' => 'admin@example.com',
'password' => 'password',
]
);
// 呼叫權限 Seeder 設定權限與角色
$this->call(PermissionSeeder::class);
// 確保 admin 擁有 super-admin 角色
if (!$admin->hasRole('super-admin')) {
$admin->assignRole('super-admin');
}
}
}