Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: added support for resourceId #169

Merged
merged 4 commits into from
Mar 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion src/Data/EventData.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class EventData implements Arrayable

protected int|string|null $groupId = null;

protected int|string|null $resourceId = null;

protected ?array $resourceIds = null;

protected bool $allDay = false;

protected DateTimeInterface|string $start;
Expand Down Expand Up @@ -59,7 +63,26 @@ public function groupId(int|string $groupId): static
}

/**
* Determines if the event is shown in the “all-day” section of relevant views. In addition, if true the time text is not displayed with the event.
* Events can be associated with a resource when its resourceId property matches one of the resource object’s id field.
*/
public function resourceId(int|string $resourceId): static
{
$this->resourceId = $resourceId;

return $this;
}
/**
* It is also possible to associate an event with multiple resources using the resourceIds property.
*/
public function resourceIds(array $resourceIds): static
{
$this->resourceIds = $resourceIds;

return $this;
}
/**
* Determines if the event is shown in the “all-day” section of relevant views. In addition,
* if true the time text is not displayed with the event.
*/
public function allDay(bool $allDay = true): static
{
Expand Down Expand Up @@ -168,6 +191,8 @@ public function toArray(): array
'start' => $this->start,
'end' => $this->end,
'title' => $this->title,
...$this->resourceId ? ['resourceId' => $this->resourceId] : [],
...$this->resourceIds ? ['resourceIds' => $this->resourceIds] : [],
...$this->url ? ['url' => $this->url, 'shouldOpenUrlInNewTab' => $this->shouldOpenUrlInNewTab] : [],
...$this->groupId ? ['groupId' => $this->groupId] : [],
...$this->allDay ? ['allDay' => $this->allDay] : [],
Expand Down