Add URL::forceScheme('https') in AppServiceProvider to ensure all generated URLs use HTTPS when the application is in production. This improves security by enforcing secure connections.
37 lines
771 B
PHP
37 lines
771 B
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Policies\RolePolicy;
|
|
use Illuminate\Support\Facades\Gate;
|
|
use Illuminate\Support\Facades\URL;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Spatie\Permission\Models\Role;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register any application services.
|
|
*/
|
|
public function register(): void
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Bootstrap any application services.
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
if ($this->app->environment('production')) {
|
|
URL::forceScheme('https');
|
|
}
|
|
|
|
Gate::before(function ($user, $ability) {
|
|
return $user->hasRole('super_admin') ? true : null;
|
|
});
|
|
|
|
Gate::policy(Role::class, RolePolicy::class);
|
|
}
|
|
}
|