52 lines
1.5 KiB
PHP
52 lines
1.5 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\Facades\Schema;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
use function auditionSetting;
|
|
|
|
/**
|
|
* @codeCoverageIgnore
|
|
*/
|
|
// TODO: Consider testing later
|
|
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 ($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'),
|
|
};
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|