<?php

namespace App\Providers;

use App\View\Composers\HeaderComposer;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
use Illuminate\Mail\Events\MessageSending;

class AppServiceProvider extends ServiceProvider
{
    public function register(): void {}

    public function boot(): void
    {
        View::composer('layouts._partials.header', HeaderComposer::class);

        Event::listen(MessageSending::class, function ($event) {
            $event->message->getHeaders()->addTextHeader(
                'List-Unsubscribe',
                '<mailto:bajas@tudominio.com>, <https://tudominio.com/unsubscribe>'
            );
            $event->message->getHeaders()->addTextHeader(
                'List-Unsubscribe-Post',
                'List-Unsubscribe=One-Click'
            );
        });
    }
}
