- 修正所有模組 Controller 的 Model 引用路徑 (App\Modules\...) - 更新 ProductionOrder 與 ProductionOrderItem 模型結構以符合新版邏輯 - 修復 resources/js/utils/format.ts 在處理空值時導致 toLocaleString 崩潰的問題 - 清除全域路徑與 Controller 遷移殘留檔案
43 lines
1.0 KiB
PHP
43 lines
1.0 KiB
PHP
<?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');
|
||
}
|
||
}
|
||
}
|