| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
-
- namespace App\Providers;
-
- use App\Billing\StripeSubscriptionGateway;
- use App\Billing\SubscriptionGateway;
- use App\Commerce\Payments\MerchantAccounts;
- use App\Commerce\Payments\PaymentGateway;
- use App\Commerce\Payments\StripeGateway;
- use App\Commerce\Payments\StripeMerchantAccounts;
- use App\Commerce\Shipping\EasyParcel\EasyParcel;
- use App\Commerce\Shipping\FlatRateShipping;
- use App\Commerce\Shipping\ShippingProvider;
- use Carbon\CarbonImmutable;
- use Illuminate\Foundation\DevCommands;
- use Illuminate\Support\Facades\Date;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\ServiceProvider;
- use Illuminate\Validation\Rules\Password;
-
- class AppServiceProvider extends ServiceProvider
- {
- /**
- * Register any application services.
- */
- public function register(): void
- {
- // Payments go through one interface, so the provider can be changed in one place.
- $this->app->bind(PaymentGateway::class, StripeGateway::class);
- // Merchants' own Stripe accounts (Stripe Connect), where shoppers' payments go.
- $this->app->bind(MerchantAccounts::class, StripeMerchantAccounts::class);
- $this->app->bind(SubscriptionGateway::class, StripeSubscriptionGateway::class);
- $this->app->bind(ShippingProvider::class, FlatRateShipping::class);
- $this->app->bind(EasyParcel::class, fn () => EasyParcel::fromConfig());
- }
-
- /**
- * Bootstrap any application services.
- */
- public function boot(): void
- {
- $this->configureDefaults();
-
- // `composer run dev` also runs the scheduler, so the double-check for unpaid orders runs on this machine too.
- DevCommands::artisan('schedule:work', 'scheduler');
- }
-
- /**
- * 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,
- );
- }
- }
|