56 lines
1.8 KiB
PHP
56 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Database\Grammars\CustomOdbcGrammar;
|
|
use App\Domain\Patient\Contracts\PatientRepositoryInterface;
|
|
use App\Infrastructure\Database\Repositories\Patient\PatientRepository;
|
|
use App\Models\DepartmentPatient;
|
|
use App\Models\ReportDuty;
|
|
use App\Models\ReportNurse;
|
|
use App\Observers\DepartmentPatientObserver;
|
|
use App\Observers\ReportDutyObserver;
|
|
use App\Observers\ReportNurseObserver;
|
|
use App\Services\Cache\CacheInvalidator;
|
|
use App\Services\Cache\CacheKeyBuilder;
|
|
use Illuminate\Database\Connection;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register any application services.
|
|
*/
|
|
public function register(): void
|
|
{
|
|
$this->app->singleton(CacheKeyBuilder::class, function () {
|
|
return new CacheKeyBuilder(version: 'v1');
|
|
});
|
|
|
|
$this->app->singleton(CacheInvalidator::class);
|
|
|
|
$this->app->bind(
|
|
PatientRepositoryInterface::class,
|
|
PatientRepository::class
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Bootstrap any application services.
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
ReportNurse::observe(ReportNurseObserver::class);
|
|
ReportDuty::observe(ReportDutyObserver::class);
|
|
DepartmentPatient::observe(DepartmentPatientObserver::class);
|
|
|
|
// Подключение DBLIB для MSSQL
|
|
Connection::resolverFor('dblib', function ($connection, $database, $prefix, $config) {
|
|
// Создаём PDO через DBLIB
|
|
$dsn = "dblib:host={$config['host']};dbname={$config['database']}";
|
|
$pdo = new \PDO($dsn, $config['username'], $config['password'], $config['options'] ?? []);
|
|
return new Connection($pdo, $database, $prefix, $config);
|
|
});
|
|
}
|
|
}
|