MINI MINI MANI MO
<?php
namespace App\Mail;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use App\Services\ICSService;
class EventNotification extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public $event;
public function __construct($event)
{
$this->event = $event;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
$ics = $this->crearArchivoICS();
return $this->view('email.calendar')
->subject('Nueva invitación a un evento')
->attachData($ics, 'evento.ics', [
'mime' => 'text/calendar',
]);
}
protected function crearArchivoICS()
{
$icsContent = "BEGIN:VCALENDAR\r\n" .
"VERSION:2.0\r\n" .
"PRODID:-//Laravel App//EN\r\n" .
"CALSCALE:GREGORIAN\r\n" .
"BEGIN:VEVENT\r\n" .
"UID:" . uniqid() . "\r\n" .
"DTSTART:" . $this->event['start'] . "\r\n" .
"DTEND:" . $this->event['end'] . "\r\n" .
"SUMMARY:" . $this->event['summary'] . "\r\n" .
"DESCRIPTION:" . $this->event['description'] . "\r\n" .
"LOCATION:" . $this->event['location'] . "\r\n" .
"END:VEVENT\r\n" .
"END:VCALENDAR\r\n";
return $icsContent;
}
}
OHA YOOOO