Files
star-erp/app/Providers/AppServiceProvider.php

31 lines
707 B
PHP
Raw Normal View History

2025-12-30 15:03:19 +08:00
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
2026-01-06 13:26:40 +08:00
use Illuminate\Support\Facades\URL;
2025-12-30 15:03:19 +08:00
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}
public function boot(): void
{
2026-01-06 13:21:31 +08:00
// 如果是在正式環境,強制轉為 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;
});
2025-12-30 15:03:19 +08:00
}
}