Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️
PHP attendize-alternativedoor-managementevent-check-inevent-managementevent-registrationevent-ticketingeventbrite-alternativeeventslaravelopen-sourcephpreactself-hostedsell-ticketssell-tickets-onlineticket-sellingticketing-systemtickettailor-alternativetito-alternative
Attach ICS calendar event to attendee ticket emails
Dave Earleya6893f599c5a
diff --git a/backend/app/DomainObjects/EventSettingDomainObject.php b/backend/app/DomainObjects/EventSettingDomainObject.phpindex cf6c350a2..46dc2fefd 100644--- a/backend/app/DomainObjects/EventSettingDomainObject.php+++ b/backend/app/DomainObjects/EventSettingDomainObject.php@@ -20,4 +20,27 @@ class EventSettingDomainObject extends Generated\EventSettingDomainObjectAbstrac</div>HTML;}++ public function getAddressString(): string+ {+ $locationDetails = $this->getLocationDetails();++ if (is_null($locationDetails)) {+ return '';+ }++ $addressParts = [+ $locationDetails['venue_name'] ?? null,+ $locationDetails['address_line_1'] ?? null,+ $locationDetails['address_line_2'] ?? null,+ $locationDetails['city'] ?? null,+ $locationDetails['state_or_region'] ?? null,+ $locationDetails['zip_or_postal_code'] ?? null,+ $locationDetails['country'] ?? null+ ];++ $filteredAddressParts = array_filter($addressParts, static fn($part) => !is_null($part) && $part !== '');++ return implode(', ', $filteredAddressParts);+ }}diff --git a/backend/app/Mail/Attendee/AttendeeTicketMail.php b/backend/app/Mail/Attendee/AttendeeTicketMail.phpindex 9e64885b4..03e357569 100644--- a/backend/app/Mail/Attendee/AttendeeTicketMail.php+++ b/backend/app/Mail/Attendee/AttendeeTicketMail.php@@ -2,14 +2,20 @@namespace HiEvents\Mail\Attendee;+use Carbon\Carbon;use HiEvents\DomainObjects\AttendeeDomainObject;use HiEvents\DomainObjects\EventDomainObject;use HiEvents\DomainObjects\EventSettingDomainObject;+use HiEvents\DomainObjects\OrganizerDomainObject;+use HiEvents\Helper\StringHelper;use HiEvents\Helper\Url;use HiEvents\Mail\BaseMail;+use Illuminate\Mail\Mailables\Attachment;use Illuminate\Mail\Mailables\Content;use Illuminate\Mail\Mailables\Envelope;use Illuminate\Support\Str;+use Spatie\IcalendarGenerator\Components\Calendar;+use Spatie\IcalendarGenerator\Components\Event;/*** @uses /backend/resources/views/emails/orders/attendee-ticket.blade.php@@ -20,6 +26,7 @@ class AttendeeTicketMail extends BaseMailprivate readonly AttendeeDomainObject $attendee,private readonly EventDomainObject $event,private readonly EventSettingDomainObject $eventSettings,+ private readonly OrganizerDomainObject $organizer,){parent::__construct();@@ -51,4 +58,38 @@ class AttendeeTicketMail extends BaseMail]);}++ public function attachments(): array+ {+ $startDateTime = Carbon::parse($this->event->getStartDate(), $this->event->getTimezone());+ $endDateTime = $this->event->getEndDate() ? Carbon::parse($this->event->getEndDate(), $this->event->getTimezone()) : null;++ $event = Event::create()+ ->name($this->event->getTitle())+ ->uniqueIdentifier('event-' . $this->attendee->getId())+ ->startsAt($startDateTime)+ ->url($this->event->getEventUrl())+ ->organizer($this->organizer->getEmail(), $this->organizer->getName());++ if ($this->event->getDescription()) {+ $event->description(StringHelper::previewFromHtml($this->event->getDescription()));+ }++ if ($this->eventSettings->getLocationDetails()) {+ $event->address($this->eventSettings->getAddressString());+ }++ if ($endDateTime) {+ $event->endsAt($endDateTime);+ }++ $calendar = Calendar::create()+ ->event($event)+ ->get();++ return [+ Attachment::fromData(static fn() => $calendar, 'event.ics')+ ->withMime('text/calendar')+ ];+ }}diff --git a/backend/app/Services/Domain/Attendee/SendAttendeeTicketService.php b/backend/app/Services/Domain/Attendee/SendAttendeeTicketService.phpindex f5075de3b..3fc48ca44 100644--- a/backend/app/Services/Domain/Attendee/SendAttendeeTicketService.php+++ b/backend/app/Services/Domain/Attendee/SendAttendeeTicketService.php@@ -5,6 +5,7 @@ namespace HiEvents\Services\Domain\Attendee;use HiEvents\DomainObjects\AttendeeDomainObject;use HiEvents\DomainObjects\EventDomainObject;use HiEvents\DomainObjects\EventSettingDomainObject;+use HiEvents\DomainObjects\OrganizerDomainObject;use HiEvents\Mail\Attendee\AttendeeTicketMail;use Illuminate\Contracts\Mail\Mailer;@@ -20,12 +21,14 @@ readonly class SendAttendeeTicketServiceAttendeeDomainObject $attendee,EventDomainObject $event,EventSettingDomainObject $eventSettings,+ OrganizerDomainObject $organizer,): void{$this->mailer->to($attendee->getEmail())->send(new AttendeeTicketMail(attendee: $attendee,event: $event,eventSettings: $eventSettings,+ organizer: $organizer,));}}diff --git a/backend/app/Services/Domain/Mail/SendOrderDetailsService.php b/backend/app/Services/Domain/Mail/SendOrderDetailsService.phpindex 398e3d20d..19a38fb74 100644--- a/backend/app/Services/Domain/Mail/SendOrderDetailsService.php+++ b/backend/app/Services/Domain/Mail/SendOrderDetailsService.php@@ -62,7 +62,13 @@ readonly class SendOrderDetailsServicecontinue;}- $this->sendAttendeeTicketService->send($attendee, $event, $event->getEventSettings());+ $this->sendAttendeeTicketService->send(+ attendee: $attendee,+ event: $event,+ eventSettings: $event->getEventSettings(),+ organizer: $event->getOrganizer(),+ );+$sentEmails[] = $attendee->getEmail();}}diff --git a/backend/app/Services/Handlers/Attendee/ResendAttendeeTicketHandler.php b/backend/app/Services/Handlers/Attendee/ResendAttendeeTicketHandler.phpindex df5eb0b95..1424a1629 100644--- a/backend/app/Services/Handlers/Attendee/ResendAttendeeTicketHandler.php+++ b/backend/app/Services/Handlers/Attendee/ResendAttendeeTicketHandler.php@@ -3,8 +3,10 @@namespace HiEvents\Services\Handlers\Attendee;use HiEvents\DomainObjects\EventSettingDomainObject;+use HiEvents\DomainObjects\OrganizerDomainObject;use HiEvents\DomainObjects\Status\AttendeeStatus;use HiEvents\Exceptions\ResourceConflictException;+use HiEvents\Repository\Eloquent\Value\Relationship;use HiEvents\Repository\Interfaces\AttendeeRepositoryInterface;use HiEvents\Repository\Interfaces\EventRepositoryInterface;use HiEvents\Services\Domain\Attendee\SendAttendeeTicketService;@@ -42,10 +44,16 @@ readonly class ResendAttendeeTicketHandler}$event = $this->eventRepository+ ->loadRelation(new Relationship(OrganizerDomainObject::class, name: 'organizer'))->loadRelation(EventSettingDomainObject::class)->findById($resendAttendeeTicketDTO->eventId);- $this->sendAttendeeTicketService->send($attendee, $event, $event->getEventSettings());+ $this->sendAttendeeTicketService->send(+ attendee: $attendee,+ event: $event,+ eventSettings: $event->getEventSettings(),+ organizer: $event->getOrganizer(),+ );$this->logger->info('Attendee ticket resent', ['attendeeId' => $resendAttendeeTicketDTO->attendeeId,diff --git a/backend/composer.json b/backend/composer.jsonindex 4dec29c50..4b4104919 100644--- a/backend/composer.json+++ b/backend/composer.json@@ -19,6 +19,7 @@"maatwebsite/excel": "^3.1","nette/php-generator": "^4.0","php-open-source-saver/jwt-auth": "^2.1",+ "spatie/icalendar-generator": "^2.8","stripe/stripe-php": "^10.15"},"require-dev": {diff --git a/backend/composer.lock b/backend/composer.lockindex 9f0d35ef5..06dfbfb93 100644--- a/backend/composer.lock+++ b/backend/composer.lock@@ -4,7 +4,7 @@"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies","This file is @generated automatically"],- "content-hash": "d8d83799f1f66406f0c41b2b51c35b10",+ "content-hash": "5f55a1a7adc1f649d32d094a084840d1","packages": [{"name": "aws/aws-crt-php",@@ -4795,6 +4795,142 @@],"time": "2023-11-08T05:53:05+00:00"},+ {+ "name": "spatie/enum",+ "version": "3.13.0",+ "source": {+ "type": "git",+ "url": "https://github.com/spatie/enum.git",+ "reference": "f1a0f464ba909491a53e60a955ce84ad7cd93a2c"+ },+ "dist": {+ "type": "zip",+ "url": "https://api.github.com/repos/spatie/enum/zipball/f1a0f464ba909491a53e60a955ce84ad7cd93a2c",+ "reference": "f1a0f464ba909491a53e60a955ce84ad7cd93a2c",+ "shasum": ""+ },+ "require": {+ "ext-json": "*",+ "php": "^8.0"+ },+ "require-dev": {+ "fakerphp/faker": "^1.9.1",+ "larapack/dd": "^1.1",+ "phpunit/phpunit": "^9.0",+ "vimeo/psalm": "^4.3"+ },+ "suggest": {+ "fakerphp/faker": "To use the enum faker provider",+ "phpunit/phpunit": "To use the enum assertions"+ },+ "type": "library",+ "autoload": {+ "psr-4": {+ "Spatie\\Enum\\": "src"+ }+ },+ "notification-url": "https://packagist.org/downloads/",+ "license": [+ "MIT"+ ],+ "authors": [+ {+ "name": "Brent Roose",+ "email": "[email protected]",+ "homepage": "https://spatie.be",+ "role": "Developer"+ },+ {+ "name": "Tom Witkowski",+ "email": "[email protected]",+ "homepage": "https://gummibeer.de",+ "role": "Developer"+ }+ ],+ "description": "PHP Enums",+ "homepage": "https://github.com/spatie/enum",+ "keywords": [+ "enum",+ "enumerable",+ "spatie"+ ],+ "support": {+ "docs": "https://docs.spatie.be/enum",+ "issues": "https://github.com/spatie/enum/issues",+ "source": "https://github.com/spatie/enum"+ },+ "funding": [+ {+ "url": "https://spatie.be/open-source/support-us",+ "type": "custom"+ },+ {+ "url": "https://github.com/spatie",+ "type": "github"+ }+ ],+ "time": "2022-04-22T08:51:55+00:00"+ },+ {+ "name": "spatie/icalendar-generator",+ "version": "2.8.0",+ "source": {+ "type": "git",+ "url": "https://github.com/spatie/icalendar-generator.git",+ "reference": "00097f69a35a4b0b98b71f4700f828ffa15a4c2d"+ },+ "dist": {+ "type": "zip",+ "url": "https://api.github.com/repos/spatie/icalendar-generator/zipball/00097f69a35a4b0b98b71f4700f828ffa15a4c2d",+ "reference": "00097f69a35a4b0b98b71f4700f828ffa15a4c2d",+ "shasum": ""+ },+ "require": {+ "ext-mbstring": "*",+ "php": "^7.4|^8.0",+ "spatie/enum": "^3.11"+ },+ "require-dev": {+ "ext-json": "*",+ "larapack/dd": "^1.1",+ "nesbot/carbon": "^2.63|^3.0",+ "pestphp/pest": "^1.22",+ "spatie/pest-plugin-snapshots": "^1.1",+ "vimeo/psalm": "^4.13"+ },+ "type": "library",+ "autoload": {+ "psr-4": {+ "Spatie\\IcalendarGenerator\\": "src"+ }+ },+ "notification-url": "https://packagist.org/downloads/",+ "license": [+ "MIT"+ ],+ "authors": [+ {+ "name": "Ruben Van Assche",+ "email": "[email protected]",+ "homepage": "https://spatie.be",+ "role": "Developer"+ }+ ],+ "description": "Build calendars in the iCalendar format",+ "homepage": "https://github.com/spatie/icalendar-generator",+ "keywords": [+ "calendar",+ "iCalendar",+ "ical",+ "ics",+ "spatie"+ ],+ "support": {+ "issues": "https://github.com/spatie/icalendar-generator/issues",+ "source": "https://github.com/spatie/icalendar-generator/tree/2.8.0"+ },+ "time": "2024-05-16T15:11:32+00:00"+ },{"name": "stripe/stripe-php","version": "v10.21.0",