41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Services\EntryService;
|
|
use App\Services\Invoice\InvoiceDataService;
|
|
use App\Services\Invoice\InvoiceOneFeePerEntry;
|
|
use App\Services\Invoice\InvoiceOneFeePerStudent;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use function auditionSetting;
|
|
|
|
class InvoiceDataServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register services.
|
|
*/
|
|
public function register(): void
|
|
{
|
|
$this->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 (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'),
|
|
};
|
|
});
|
|
}
|
|
}
|
|
}
|