Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.7.1-beta
v1.7.1-beta.1
14 changes: 14 additions & 0 deletions backend/app/DomainObjects/AttendeeDomainObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class AttendeeDomainObject extends Generated\AttendeeDomainObjectAbstract implem
/** @var Collection<AttendeeCheckInDomainObject>|null */
private ?Collection $checkIns = null;

private ?EventOccurrenceDomainObject $eventOccurrence = null;

public static function getDefaultSort(): string
{
return self::CREATED_AT;
Expand Down Expand Up @@ -71,6 +73,7 @@ public static function getAllowedFilterFields(): array
self::STATUS,
self::PRODUCT_ID,
self::PRODUCT_PRICE_ID,
self::EVENT_OCCURRENCE_ID,
];
}

Expand Down Expand Up @@ -138,4 +141,15 @@ public function getCheckIns(): ?Collection
{
return $this->checkIns;
}

public function setEventOccurrence(?EventOccurrenceDomainObject $eventOccurrence): AttendeeDomainObject
{
$this->eventOccurrence = $eventOccurrence;
return $this;
}

public function getEventOccurrence(): ?EventOccurrenceDomainObject
{
return $this->eventOccurrence;
}
}
14 changes: 14 additions & 0 deletions backend/app/DomainObjects/CheckInListDomainObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class CheckInListDomainObject extends Generated\CheckInListDomainObjectAbstract

private ?EventDomainObject $event = null;

private ?EventOccurrenceDomainObject $eventOccurrence = null;

private ?int $checkedInCount = null;

private ?int $totalAttendeesCount = null;
Expand Down Expand Up @@ -77,6 +79,18 @@ public function setEvent(?EventDomainObject $event): static
return $this;
}

public function getEventOccurrence(): ?EventOccurrenceDomainObject
{
return $this->eventOccurrence;
}

public function setEventOccurrence(?EventOccurrenceDomainObject $eventOccurrence): static
{
$this->eventOccurrence = $eventOccurrence;

return $this;
}

public function isExpired(string $timezone): bool
{
if ($this->getExpiresAt() === null) {
Expand Down
12 changes: 12 additions & 0 deletions backend/app/DomainObjects/Enums/BulkOccurrenceAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace HiEvents\DomainObjects\Enums;

enum BulkOccurrenceAction: string
{
use BaseEnum;

case UPDATE = 'update';
case CANCEL = 'cancel';
case DELETE = 'delete';
}
12 changes: 12 additions & 0 deletions backend/app/DomainObjects/Enums/EmailTemplateType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ enum EmailTemplateType: string

case ORDER_CONFIRMATION = 'order_confirmation';
case ATTENDEE_TICKET = 'attendee_ticket';
case OCCURRENCE_CANCELLATION = 'occurrence_cancellation';

public function label(): string
{
return match ($this) {
self::ORDER_CONFIRMATION => __('Order Confirmation'),
self::ATTENDEE_TICKET => __('Attendee Ticket'),
self::OCCURRENCE_CANCELLATION => __('Date Cancellation'),
};
}

Expand All @@ -22,6 +24,16 @@ public function description(): string
return match ($this) {
self::ORDER_CONFIRMATION => __('Sent to the customer after placing an order'),
self::ATTENDEE_TICKET => __('Sent to each attendee with their ticket'),
self::OCCURRENCE_CANCELLATION => __('Sent to attendees when a scheduled date is cancelled'),
};
}

public function ctaUrlToken(): string
{
return match ($this) {
self::ORDER_CONFIRMATION => 'order.url',
self::ATTENDEE_TICKET => 'ticket.url',
self::OCCURRENCE_CANCELLATION => 'event.url',
};
}
}
11 changes: 11 additions & 0 deletions backend/app/DomainObjects/Enums/EventType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace HiEvents\DomainObjects\Enums;

enum EventType
{
use BaseEnum;

case SINGLE;
case RECURRING;
}
1 change: 1 addition & 0 deletions backend/app/DomainObjects/Enums/ReportTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ enum ReportTypes: string
case PRODUCT_SALES = 'product_sales';
case DAILY_SALES_REPORT = 'daily_sales_report';
case PROMO_CODES_REPORT = 'promo_codes_report';
case OCCURRENCE_SUMMARY = 'occurrence_summary';
}
139 changes: 105 additions & 34 deletions backend/app/DomainObjects/EventDomainObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
namespace HiEvents\DomainObjects;

use Carbon\Carbon;
use HiEvents\DomainObjects\Enums\EventType;
use HiEvents\DomainObjects\Interfaces\IsFilterable;
use HiEvents\DomainObjects\Interfaces\IsSortable;
use HiEvents\DomainObjects\SortingAndFiltering\AllowedSorts;
use HiEvents\DomainObjects\Status\EventLifecycleStatus;
use HiEvents\DomainObjects\Status\EventOccurrenceStatus;
use HiEvents\Helper\StringHelper;
use HiEvents\Helper\Url;
use Illuminate\Support\Collection;
Expand All @@ -32,6 +34,8 @@ class EventDomainObject extends Generated\EventDomainObjectAbstract implements I

private ?Collection $affiliates = null;

private ?Collection $eventOccurrences = null;

private ?EventSettingDomainObject $settings = null;

private ?OrganizerDomainObject $organizer = null;
Expand All @@ -44,8 +48,6 @@ public static function getAllowedFilterFields(): array
{
return [
self::TITLE,
self::START_DATE,
self::END_DATE,
self::CREATED_AT,
self::UPDATED_AT,
self::STATUS,
Expand All @@ -57,14 +59,6 @@ public static function getAllowedSorts(): AllowedSorts
{
return new AllowedSorts(
[
self::START_DATE => [
'asc' => __('Closest start date'),
'desc' => __('Furthest start date'),
],
self::END_DATE => [
'asc' => __('Closest end date'),
'desc' => __('Furthest end date'),
],
self::CREATED_AT => [
'desc' => __('Newest first'),
'asc' => __('Oldest first'),
Expand All @@ -79,12 +73,12 @@ public static function getAllowedSorts(): AllowedSorts

public static function getDefaultSort(): string
{
return self::START_DATE;
return self::CREATED_AT;
}

public static function getDefaultSortDirection(): string
{
return 'asc';
return 'desc';
}

public function setProducts(Collection $products): self
Expand Down Expand Up @@ -178,58 +172,135 @@ public function getDescriptionPreview(): string
return StringHelper::previewFromHtml($this->getDescription());
}

public function setEventOccurrences(?Collection $eventOccurrences): self
{
$this->eventOccurrences = $eventOccurrences;
return $this;
}

public function getEventOccurrences(): ?Collection
{
return $this->eventOccurrences;
}

public function getStartDate(): ?string
{
if ($this->eventOccurrences === null || $this->eventOccurrences->isEmpty()) {
return null;
}

return $this->eventOccurrences->min(
fn(EventOccurrenceDomainObject $o) => $o->getStartDate()
);
}

public function getEndDate(): ?string
{
if ($this->eventOccurrences === null || $this->eventOccurrences->isEmpty()) {
return null;
}

$withEndDates = $this->eventOccurrences->filter(
fn(EventOccurrenceDomainObject $o) => $o->getEndDate() !== null
);

if ($withEndDates->isEmpty()) {
return $this->eventOccurrences->max(
fn(EventOccurrenceDomainObject $o) => $o->getStartDate()
);
}

return $withEndDates->max(
fn(EventOccurrenceDomainObject $o) => $o->getEndDate()
);
}

public function getNextOccurrenceStartDate(): ?string
{
if ($this->eventOccurrences === null || $this->eventOccurrences->isEmpty()) {
return null;
}

$now = Carbon::now();

$nextOccurrence = $this->eventOccurrences
->filter(fn(EventOccurrenceDomainObject $o) => $o->getStatus() === EventOccurrenceStatus::ACTIVE->name)
->filter(fn(EventOccurrenceDomainObject $o) => Carbon::parse($o->getStartDate(), 'UTC')->isFuture())
->sortBy(fn(EventOccurrenceDomainObject $o) => $o->getStartDate())
->first();

return $nextOccurrence?->getStartDate();
}

public function isEventInPast(): bool
{
if ($this->getEndDate() === null) {
$endDate = $this->getEndDate();
if ($endDate === null) {
return false;
}
$endDate = Carbon::parse($this->getEndDate());
$endDate->setTimezone($this->getTimezone());

return $endDate->isPast();
$parsed = Carbon::parse($endDate);
if ($this->getTimezone()) {
$parsed->setTimezone($this->getTimezone());
}

return $parsed->isPast();
}

public function isEventInFuture(): bool
{
if ($this->getStartDate() === null) {
$startDate = $this->getStartDate();
if ($startDate === null) {
return false;
}
$startDate = Carbon::parse($this->getStartDate());
$startDate->setTimezone($this->getTimezone());

return $startDate->isFuture();
$parsed = Carbon::parse($startDate);
if ($this->getTimezone()) {
$parsed->setTimezone($this->getTimezone());
}

return $parsed->isFuture();
}

public function isEventOngoing(): bool
{
$startDate = Carbon::parse($this->getStartDate());
$startDate->setTimezone($this->getTimezone());

if ($this->getEndDate() === null) {
return $startDate->isPast();
if ($this->eventOccurrences === null || $this->eventOccurrences->isEmpty()) {
return false;
}

$endDate = Carbon::parse($this->getEndDate());
$endDate->setTimezone($this->getTimezone());
foreach ($this->eventOccurrences as $occurrence) {
if ($occurrence->getStatus() !== EventOccurrenceStatus::ACTIVE->name) {
continue;
}

return $startDate->isPast() && $endDate->isFuture();
$start = Carbon::parse($occurrence->getStartDate(), 'UTC');
$end = $occurrence->getEndDate() ? Carbon::parse($occurrence->getEndDate(), 'UTC') : null;

if ($start->isPast() && ($end === null || $end->isFuture())) {
return true;
}
}

return false;
}

public function getLifecycleStatus(): string
{
if ($this->isEventInPast()) {
return EventLifecycleStatus::ENDED->name;
if ($this->isEventOngoing()) {
return EventLifecycleStatus::ONGOING->name;
}

if ($this->isEventInFuture()) {
return EventLifecycleStatus::UPCOMING->name;
}

if ($this->isEventOngoing()) {
return EventLifecycleStatus::ONGOING->name;
}

return EventLifecycleStatus::ENDED->name;

}

public function isRecurring(): bool
{
return $this->getType() === EventType::RECURRING->name;
}

public function getPromoCodes(): ?Collection
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace HiEvents\DomainObjects;

class EventOccurrenceDailyStatisticDomainObject extends Generated\EventOccurrenceDailyStatisticDomainObjectAbstract
{
}
Loading
Loading