-
-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #117 from HiEventsDev/develop
main <- develop
- Loading branch information
Showing
136 changed files
with
5,838 additions
and
2,051 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
86 changes: 86 additions & 0 deletions
86
backend/app/DomainObjects/CapacityAssignmentDomainObject.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
namespace HiEvents\DomainObjects; | ||
|
||
use HiEvents\Constants; | ||
use HiEvents\DomainObjects\Interfaces\IsSortable; | ||
use HiEvents\DomainObjects\SortingAndFiltering\AllowedSorts; | ||
use Illuminate\Support\Collection; | ||
|
||
class CapacityAssignmentDomainObject extends Generated\CapacityAssignmentDomainObjectAbstract implements IsSortable | ||
{ | ||
public ?Collection $tickets = null; | ||
|
||
public static function getDefaultSort(): string | ||
{ | ||
return static::CREATED_AT; | ||
} | ||
|
||
public static function getDefaultSortDirection(): string | ||
{ | ||
return 'desc'; | ||
} | ||
|
||
public static function getAllowedSorts(): AllowedSorts | ||
{ | ||
return new AllowedSorts( | ||
[ | ||
self::NAME => [ | ||
'asc' => __('Name A-Z'), | ||
'desc' => __('Name Z-A'), | ||
], | ||
self::CREATED_AT => [ | ||
'asc' => __('Oldest first'), | ||
'desc' => __('Newest first'), | ||
], | ||
self::UPDATED_AT => [ | ||
'asc' => __('Updated oldest first'), | ||
'desc' => __('Updated newest first'), | ||
], | ||
self::USED_CAPACITY => [ | ||
'desc' => __('Most capacity used'), | ||
'asc' => __('Least capacity used'), | ||
], | ||
self::CAPACITY => [ | ||
'desc' => __('Least capacity'), | ||
'asc' => __('Most capacity'), | ||
], | ||
] | ||
); | ||
} | ||
|
||
public function getPercentageUsed(): float | ||
{ | ||
if (!$this->getCapacity()) { | ||
return 0; | ||
} | ||
|
||
return round(($this->getUsedCapacity() / $this->getCapacity()) * 100, 2); | ||
} | ||
|
||
public function getTickets(): ?Collection | ||
{ | ||
return $this->tickets; | ||
} | ||
|
||
public function setTickets(?Collection $tickets): static | ||
{ | ||
$this->tickets = $tickets; | ||
|
||
return $this; | ||
} | ||
|
||
public function isCapacityUnlimited(): bool | ||
{ | ||
return is_null($this->getCapacity()); | ||
} | ||
|
||
public function getAvailableCapacity(): int | ||
{ | ||
if ($this->isCapacityUnlimited()) { | ||
return Constants::INFINITE; | ||
} | ||
|
||
return $this->getCapacity() - $this->getUsedCapacity(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
backend/app/DomainObjects/Enums/CapacityAssignmentAppliesTo.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace HiEvents\DomainObjects\Enums; | ||
|
||
enum CapacityAssignmentAppliesTo | ||
{ | ||
use BaseEnum; | ||
|
||
case TICKETS; | ||
case EVENT; | ||
} |
Oops, something went wrong.