Feat: Add teamer filter
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
abstract class AbstractFilterDto
|
||||
{
|
||||
public function isActive(): bool
|
||||
{
|
||||
return $this->getActiveFiltersCount() > 0;
|
||||
}
|
||||
|
||||
public function getActiveFiltersCount(): int
|
||||
{
|
||||
$freshInstance = new static();
|
||||
$filterCount = 0;
|
||||
$reflection = new \ReflectionClass(static::class);
|
||||
|
||||
foreach ($reflection->getProperties() as $property) {
|
||||
$name = $property->getName();
|
||||
if ($this->$name !== $freshInstance->$name) {
|
||||
++$filterCount;
|
||||
}
|
||||
}
|
||||
|
||||
return $filterCount;
|
||||
}
|
||||
}
|
||||
@@ -5,39 +5,18 @@ namespace App\Model;
|
||||
use App\Entity\Destination;
|
||||
use App\Entity\JobProfile;
|
||||
|
||||
class AssignmentFilterDto
|
||||
class AssignmentFilterDto extends AbstractFilterDto
|
||||
{
|
||||
public const DURATION_WEEKEND = 1;
|
||||
public const DURATION_MID_WEEK = 2;
|
||||
public const DURATION_FULL_WEEK = 3;
|
||||
public const DURATION_MORE = 4;
|
||||
|
||||
private ?\DateTimeImmutable $dateFrom = null;
|
||||
private ?\DateTimeImmutable $dateTo = null;
|
||||
private ?JobProfile $jobProfile = null;
|
||||
private ?Destination $destination = null;
|
||||
private ?int $duration = null;
|
||||
|
||||
public function isActive(): bool
|
||||
{
|
||||
return $this->getActiveFiltersCount() > 0;
|
||||
}
|
||||
|
||||
public function getActiveFiltersCount(): int
|
||||
{
|
||||
$freshInstance = new static();
|
||||
$filterCount = 0;
|
||||
$reflection = new \ReflectionClass(static::class);
|
||||
|
||||
foreach ($reflection->getProperties() as $property) {
|
||||
$name = $property->getName();
|
||||
if ($this->$name !== $freshInstance->$name) {
|
||||
++$filterCount;
|
||||
}
|
||||
}
|
||||
|
||||
return $filterCount;
|
||||
}
|
||||
protected ?\DateTimeImmutable $dateFrom = null;
|
||||
protected ?\DateTimeImmutable $dateTo = null;
|
||||
protected ?JobProfile $jobProfile = null;
|
||||
protected ?Destination $destination = null;
|
||||
protected ?int $duration = null;
|
||||
|
||||
public function getDateFrom(): ?\DateTimeImmutable
|
||||
{
|
||||
@@ -98,9 +77,4 @@ class AssignmentFilterDto
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isReset(): bool
|
||||
{
|
||||
return $this->reset;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
use App\Entity\JobProfile;
|
||||
|
||||
class TeamerFilterDto extends AbstractFilterDto
|
||||
{
|
||||
protected ?string $name = null;
|
||||
protected ?\DateTimeImmutable $dateFrom = null;
|
||||
protected ?\DateTimeImmutable $dateTo = null;
|
||||
protected ?JobProfile $jobProfile = null;
|
||||
protected string $pickupId = '';
|
||||
protected bool $skiLicense = false;
|
||||
protected bool $snowboardLicense = false;
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(?string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDateFrom(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->dateFrom;
|
||||
}
|
||||
|
||||
public function setDateFrom(?\DateTimeImmutable $dateFrom): static
|
||||
{
|
||||
$this->dateFrom = $dateFrom;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDateTo(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->dateTo;
|
||||
}
|
||||
|
||||
public function setDateTo(?\DateTimeImmutable $dateTo): static
|
||||
{
|
||||
$this->dateTo = $dateTo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getJobProfile(): ?JobProfile
|
||||
{
|
||||
return $this->jobProfile;
|
||||
}
|
||||
|
||||
public function setJobProfile(?JobProfile $jobProfile): static
|
||||
{
|
||||
$this->jobProfile = $jobProfile;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPickupId(): string
|
||||
{
|
||||
return $this->pickupId;
|
||||
}
|
||||
|
||||
public function setPickupId(string $pickupId): static
|
||||
{
|
||||
$this->pickupId = $pickupId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function hasSkiLicense(): bool
|
||||
{
|
||||
return $this->skiLicense;
|
||||
}
|
||||
|
||||
public function setSkiLicense(bool $skiLicense): static
|
||||
{
|
||||
$this->skiLicense = $skiLicense;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function hasSnowboardLicense(): bool
|
||||
{
|
||||
return $this->snowboardLicense;
|
||||
}
|
||||
|
||||
public function setSnowboardLicense(bool $snowboardLicense): static
|
||||
{
|
||||
$this->snowboardLicense = $snowboardLicense;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user