Files
star-erp/app/Providers/AppServiceProvider.php
sky121113 a0a61ba683
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Successful in 47s
Koori-ERP-Deploy-System / deploy-production (push) Has been skipped
feat: 確保 super-admin 角色擁有系統所有權限且開啟 Gate bypass
2026-01-13 17:21:36 +08:00

31 lines
707 B
PHP

<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\URL;
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;
});
}
}