<?php

declare(strict_types=1);

namespace Tricks\LaravelTools\Mail;

use Illuminate\Mail\Mailable as BaseMailable;
use Illuminate\Queue\SerializesModels;
use Tricks\LaravelTools\Data\AttachmentData;

abstract class Mailable extends BaseMailable
{
    use SerializesModels;

    /** @var AttachmentData[] */
    public array $files = [];

    /**
     * @return AttachmentData[]
     */
    public function attachments(): array
    {
        return $this->files;
    }

    public function logo(string $path): static
    {
        if ($logo = file_get_contents(public_path('logo.png'))) {
            $this->with('image', 'data:image/png;base64,'.base64_encode($logo));
        }

        return $this;
    }

    public function sender(string $sender): static
    {
        return $this->with('sender', $sender);
    }
}
