<?php

namespace Mtc\Plugins\Upsells\Providers;

use Illuminate\Support\Facades\Event;
use Illuminate\Support\ServiceProvider;
use Mtc\Plugins\Upsells\Classes\Upsells;
use Mtc\Shop\Events\ItemAdminTabnavEvent;

class UpsellsServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        $this->mergeConfigFrom(__DIR__ . '/../config/upsells.php', 'upsells');
    }

    public function boot(): void
    {
        $this->loadMigrationsFrom(__DIR__ . '/../database/migrations');

        // Add the "Upsells" tab to the product admin tabnav.
        Event::listen(ItemAdminTabnavEvent::class, function (ItemAdminTabnavEvent $event) {
            return Upsells::addTabNav($event->getItem(), $event->getRequest(), app('twig'));
        });
    }
}
