app->singleton(InvoiceDataService::class, function ($app) { // Default binding, can be overridden in booth method return new InvoiceOneFeePerEntry($app->make(EntryService::class)); }); } /** * Bootstrap services. */ public function boot(): void { if ($this->app->runningInConsole() || ! Schema::hasTable('site_settings')) { return; } if (! app()->environment('testing')) { if (auditionSetting('fee_structure')) { $this->app->singleton(InvoiceDataService::class, function ($app) { return match (auditionSetting('fee_structure')) { 'oneFeePerEntry' => new InvoiceOneFeePerEntry($app->make(EntryService::class)), 'oneFeePerStudent' => new InvoiceOneFeePerStudent($app->make(EntryService::class)), default => throw new \Exception('Unknown Invoice Method'), }; }); } } } }