mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Update schema to store accompanying period work referrer history
This commit is contained in:
@@ -156,7 +156,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
|
||||
|
||||
/**
|
||||
* @var Collection<int, AccompanyingPeriodWorkReferrerHistory>
|
||||
* @ORM\OneToMany(targetEntity=AccompanyingPeriodWorkReferrerHistory::class, cascade={"persist", "remove"}, mappedBy="accompanyingPeriodWork")
|
||||
* @ORM\OneToMany(targetEntity=AccompanyingPeriodWorkReferrerHistory::class, cascade={"persist", "remove"}, mappedBy="accompanyingPeriodWork", orphanRemoval=true)
|
||||
* @ORM\JoinTable(name="chill_person_accompanying_period_work_referrer")
|
||||
*/
|
||||
private Collection $referrersHistory;
|
||||
@@ -357,9 +357,17 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
|
||||
*/
|
||||
public function getReferrers(): ReadableCollection
|
||||
{
|
||||
return $this->referrersHistory->map(fn (AccompanyingPeriodWorkReferrerHistory $h) => $h->getUser());
|
||||
return $this->referrersHistory
|
||||
->filter(fn (AccompanyingPeriodWorkReferrerHistory $h) => null === $h->getEndDate())
|
||||
->map(fn (AccompanyingPeriodWorkReferrerHistory $h) => $h->getUser());
|
||||
}
|
||||
|
||||
public function getReferrersHistory(): Collection
|
||||
{
|
||||
return $this->referrersHistory;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Collection<int, Result>
|
||||
*/
|
||||
@@ -442,6 +450,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
|
||||
|
||||
if ($history->isDateRangeEmpty()) {
|
||||
$history->removeAccompanyingPeriodWork();
|
||||
$this->referrersHistory->removeElement($history);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -38,29 +38,24 @@ class AccompanyingPeriodWorkReferrerHistory implements TrackCreationInterface, T
|
||||
* @var \DateTimeImmutable|null
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
*/
|
||||
private ?\DateTimeImmutable $endDate;
|
||||
|
||||
/**
|
||||
* @var AccompanyingPeriodWork|null
|
||||
* @ORM\ManyToOne(targetEntity=AccompanyingPeriodWork::class, inversedBy="referrersHistory")
|
||||
*/
|
||||
private ?AccompanyingPeriodWork $accompanyingPeriodWork;
|
||||
private ?\DateTimeImmutable $endDate = null;
|
||||
|
||||
public function __construct(
|
||||
AccompanyingPeriodWork $accompanyingPeriodWork,
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=AccompanyingPeriodWork::class, inversedBy="referrersHistory")
|
||||
*/
|
||||
private ?AccompanyingPeriodWork $accompanyingPeriodWork,
|
||||
/**
|
||||
* @var User
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
*/
|
||||
private readonly User $user,
|
||||
private User $user,
|
||||
/**
|
||||
* @var \DateTimeImmutable
|
||||
* @ORM\Column(type="date_immutable", nullable=false)
|
||||
*/
|
||||
private readonly \DateTimeImmutable $startDate,
|
||||
) {
|
||||
$this->accompanyingPeriodWork = $accompanyingPeriodWork;
|
||||
}
|
||||
private \DateTimeImmutable $startDate
|
||||
) {}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
|
Reference in New Issue
Block a user