Files
mytodos/app/Providers/AppServiceProvider.php
T

77 lines
1.9 KiB
PHP
Raw Normal View History

2026-09-17 23:01:26 -07:00
<?php
namespace App\Providers;
2026-10-04 20:34:19 -07:00
use App\Http\Responses\RegisterResponse;
use App\Models\Organization;
2026-09-17 23:01:26 -07:00
use Carbon\CarbonImmutable;
use Illuminate\Support\Facades\Date;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\ServiceProvider;
use Illuminate\Validation\Rules\Password;
2026-10-04 20:34:19 -07:00
use Laravel\Cashier\Cashier;
use Laravel\Fortify\Contracts\RegisterResponse as RegisterResponseContract;
2026-09-17 23:01:26 -07:00
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
2026-10-04 20:34:19 -07:00
$this->registerFortifyResponses();
}
/**
* Swap Fortify's registration response for one that starts checkout for the
* plan the account signed up with.
*/
protected function registerFortifyResponses(): void
{
$this->app->singleton(
RegisterResponseContract::class,
RegisterResponse::class,
);
2026-09-17 23:01:26 -07:00
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
$this->configureDefaults();
2026-10-04 20:34:19 -07:00
$this->configureCashier();
}
/**
* Make organizations, rather than users, the Stripe customer. This also
* determines the foreign key Cashier uses on the subscriptions table.
*/
protected function configureCashier(): void
{
Cashier::useCustomerModel(Organization::class);
2026-09-17 23:01:26 -07:00
}
/**
* Configure default behaviors for production-ready applications.
*/
protected function configureDefaults(): void
{
Date::use(CarbonImmutable::class);
DB::prohibitDestructiveCommands(
app()->isProduction(),
);
Password::defaults(fn (): ?Password => app()->isProduction()
? Password::min(12)
->mixedCase()
->letters()
->numbers()
->symbols()
->uncompromised()
: null,
);
}
}