<?php
namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Collection;

class ReporteVentasMail extends Mailable
{
    use Queueable, SerializesModels;

    public $ventas;
    public $fromDate;
    public $toDate;
    public $email;

    // Constructor recibe también el correo
    public function __construct(Collection $ventas, $fromDate, $toDate, $email)
    {
        $this->ventas = $ventas;
        $this->fromDate = $fromDate;
        $this->toDate = $toDate;
        $this->email = $email;  // Guardamos el correo
    }

    public function build()
    {
        return $this->subject('Reporte de Ventas')
            ->to($this->email)  // Enviamos el correo a la dirección proporcionada
            ->view('emails.reporte-ventas');
    }
}
