<?php

namespace Modules\PhysiotherapyClinic\Providers;

use Illuminate\Support\ServiceProvider;

/** Thin ClinicCore specialty-plugin provider for Physiotherapy & Sport Injuries. */
class PhysiotherapyClinicServiceProvider extends ServiceProvider
{
    public function boot()
    {
        $this->registerViews();
        $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
        $this->registerSpecialtyDriver();
    }

    public function register() {}

    public function registerViews()
    {
        $sourcePath = __DIR__ . '/../Resources/views';
        $this->loadViewsFrom(array_merge(array_map(function ($path) {
            return $path . '/modules/physiotherapyClinic';
        }, \Config::get('view.paths')), [$sourcePath]), 'physiotherapyClinic');
    }

    protected function registerSpecialtyDriver(): void
    {
        try {
            if (class_exists(\Modules\ClinicCore\Entities\Services\SpecialtyDriverRegistry::class)) {
                \Modules\ClinicCore\Entities\Services\SpecialtyDriverRegistry::register(
                    new \Modules\PhysiotherapyClinic\Entities\Drivers\PhysiotherapySpecialtyDriver()
                );
            }
        } catch (\Throwable $e) {}
    }
}
