- 安裝並設定 stancl/tenancy 套件 - 分離 Central / Tenant migrations - 建立 Tenant Model 與資料遷移指令 - 建立房東後台 CRUD (Landlord Dashboard) - 新增租戶管理頁面 (列表、新增、編輯、詳情) - 新增域名管理功能 - 更新部署手冊
40 lines
1.0 KiB
PHP
40 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Illuminate\Support\Facades\URL;
|
|
use Illuminate\Support\Facades\Route;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register any application services.
|
|
*/
|
|
public function register(): void
|
|
{
|
|
//
|
|
}
|
|
|
|
public function boot(): void
|
|
{
|
|
// 如果是在正式環境,強制轉為 https
|
|
if (config('app.env') === 'production') {
|
|
URL::forceScheme('https');
|
|
}
|
|
|
|
// 隱含授權:讓 "super-admin" 角色擁有所有權限
|
|
\Illuminate\Support\Facades\Gate::before(function ($user, $ability) {
|
|
return $user->hasRole('super-admin') ? true : null;
|
|
});
|
|
|
|
// 載入房東後台路由 (只在 central domain 可用)
|
|
$this->app->booted(function () {
|
|
if (file_exists(base_path('routes/landlord.php'))) {
|
|
Route::middleware('web')->group(base_path('routes/landlord.php'));
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|