You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.0 KiB
40 lines
1.0 KiB
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Services\Sms\DisabledSmsSender;
|
|
use App\Services\Sms\SmsSender;
|
|
use App\Services\Sms\SubmailSmsSender;
|
|
use App\Services\Sms\TencentCloudSmsSender;
|
|
use Illuminate\Support\Facades\URL;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register any application services.
|
|
*/
|
|
public function register(): void
|
|
{
|
|
$this->app->bind(SmsSender::class, function ($app) {
|
|
if (! (bool) config('sms.enabled')) {
|
|
return $app->make(DisabledSmsSender::class);
|
|
}
|
|
|
|
return (string) config('sms.driver') === 'tencentcloud'
|
|
? $app->make(TencentCloudSmsSender::class)
|
|
: $app->make(SubmailSmsSender::class);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Bootstrap any application services.
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
if (str_starts_with((string) config('app.url'), 'https://')) {
|
|
URL::forceScheme('https');
|
|
}
|
|
}
|
|
}
|