adrema/app/Providers/BaseServiceProvider.php

57 lines
1.8 KiB
PHP
Raw Normal View History

2024-09-23 23:49:17 +02:00
<?php
2024-10-13 21:00:47 +02:00
namespace App\Providers;
2024-09-23 23:49:17 +02:00
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Blade;
use Illuminate\View\ComponentAttributeBag;
use Livewire\Livewire;
2024-09-24 01:26:08 +02:00
use Modules\Base\Components\Page\Sidebar;
2024-09-23 23:49:17 +02:00
use Modules\Dashboard\DashboardFactory;
use Modules\Invoice\MemberPaymentBlock;
use Modules\Member\AgeGroupCountBlock;
use Modules\Member\TestersBlock;
use Modules\Prevention\EfzPendingBlock;
use Modules\Prevention\PsPendingBlock;
2024-09-24 01:26:08 +02:00
class BaseServiceProvider extends ServiceProvider
2024-09-23 23:49:17 +02:00
{
/**
* Register services.
*/
public function register(): void
{
2024-10-13 21:00:47 +02:00
Blade::componentNamespace('App\\View\\Ui', 'ui');
Blade::componentNamespace('App\\View\\Page', 'page');
2024-10-14 20:25:11 +02:00
Blade::componentNamespace('App\\View\\Form', 'form');
2024-09-23 23:49:17 +02:00
app(DashboardFactory::class)->register(AgeGroupCountBlock::class);
app(DashboardFactory::class)->register(MemberPaymentBlock::class);
app(DashboardFactory::class)->register(TestersBlock::class);
app(DashboardFactory::class)->register(EfzPendingBlock::class);
app(DashboardFactory::class)->register(PsPendingBlock::class);
ComponentAttributeBag::macro('mergeWhen', function ($condition, $key, $attributes) {
/** @var ComponentAttributeBag */
$self = $this;
return $condition ? $self->merge([$key => $attributes]) : $self;
});
2024-10-14 00:07:39 +02:00
Livewire::resolveMissingComponent(function ($name) {
'modules.dashboard.components.dashboard-component';
if (str($name)->startsWith('modules.')) {
return str($name)->explode('.')->map(fn ($name) => str($name)->studly()->toString())->implode('\\');
}
return null;
});
2024-09-23 23:49:17 +02:00
}
/**
* Bootstrap services.
*/
public function boot(): void
{
}
}