<?php

namespace App\Providers;

use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\View;
use App\Models\CustomOffer;
use App\Models\Order;
use App\Models\Product;
use App\Models\Shipping;
use App\Observers\CustomOfferObserver;
use App\Observers\OrderObserver;
use App\Observers\ProductObserver;
use App\Observers\ShippingObserver;
use App\View\Composers\TrackingComposer;

class EventServiceProvider extends ServiceProvider
{
    /**
     * The event to listener mappings for the application.
     *
     * @var array<class-string, array<int, class-string>>
     */
    protected $listen = [
        Registered::class => [
            SendEmailVerificationNotification::class,
        ],
    ];

    /**
     * Register any events for your application.
     *
     * @return void
     */
    public function boot()
    {
        Product::observe(ProductObserver::class);
        CustomOffer::observe(CustomOfferObserver::class);
        Order::observe(OrderObserver::class);
        Shipping::observe(ShippingObserver::class);

        // Data Layer & Tracking - share pixels, GTM, TikTok with frontend
        View::composer('frontEnd.layouts.master', TrackingComposer::class);
    }

    /**
     * Determine if events and listeners should be automatically discovered.
     *
     * @return bool
     */
    public function shouldDiscoverEvents()
    {
        return false;
    }
}
