Laravel Google calendar add to calendar link in email

Viewed 15

i can't generate "add to calendar" link. I am using laravel mailable ,spatie package and carbon for google calendar im trying this with laravel 9 im stuck and any help or suggestion will helps a lot ty. but my code view this (image down below)

enter image description here

but i want this format (image down below) with google calendar api

enter image description here

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Spatie\IcalendarGenerator\Components\Calendar;
use Spatie\IcalendarGenerator\Components\Event;
use Spatie\IcalendarGenerator\Properties\TextProperty;
use Carbon\Carbon;
use DateTime;
use Illuminate\Notifications\Messages\MailMessage;
use Spatie\CalendarLinks\Link;

class InformationMail extends Mailable
{
    use Queueable, SerializesModels;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($data)
    {
        $this->data = $data;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {

       
        if($this->data['isCustomEmailSend'])
        {
            $calendar = Calendar::create()
            ->productIdentifier($this->data['companyName'])
            ->event(function (Event $event) {
                $event->name($this->data['companyName'])
                    ->attendee($this->data['email'])
                    ->organizer($this->data['from'], $this->data['companyName'])
                    ->startsAt(Carbon::parse($this->data['appDate']))
                    ->fullDay()
                    ->address('Online - Google Meet');
            });
            $calendar->appendProperty(TextProperty::create('METHOD', 'REQUEST'));        

           

            return $this->view('cemail')
                    ->subject($this->data['sub'])
                    ->from($this->data['from'],$this->data['companyName'])
                    ->html($this->data['customEmailContent'])
                    ->with('data',$this->data)
                    ->attachData($calendar->get(), 'invite.ics', [
                        'mime' => 'text/calendar; charset=UTF-8; method=REQUEST',
                    ]);
        }
        else 
        {
            $calendar = Calendar::create()
            ->productIdentifier($this->data['companyName'])
            ->event(function (Event $event) {
                $event->name($this->data['companyName'])
                    ->attendee($this->data['email'])
                    ->organizer($this->data['from'], $this->data['companyName'])
                    ->startsAt(Carbon::parse($this->data['appDate']))
                    ->fullDay()
                    ->address('Online - Google Meet');
            });
            $calendar->appendProperty(TextProperty::create('METHOD', 'REQUEST'));      

            return $this->view('email')
                    ->subject($this->data['sub'])
                    ->from($this->data['from'],$this->data['companyName'])                   
                    ->with('data',$this->data)
                    ->attachData($calendar->get(), 'invite.ics', [
                        'mime' => 'text/calendar; charset=UTF-8; method=REQUEST',
                    ]);
        }

        

        
    }
}

0 Answers
Related