migration for history, and create history location on each change

This commit is contained in:
2022-02-14 23:03:40 +01:00
parent 441704dc29
commit b9dbb1916a
6 changed files with 324 additions and 173 deletions

View File

@@ -1,18 +1,41 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
use Chill\MainBundle\Entity\Address;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
* @ORM\Entity
* @ORM\Table("chill_person_accompanying_period_location_history")
*/
class AccompanyingPeriodLocationHistory
{
use TrackCreationTrait;
/**
* @ORM\ManyToOne(targetEntity=Address::class)
*/
private ?Address $addressLocation = null;
/**
* @ORM\Column(type="date_immutable")
*/
private ?DateTimeImmutable $endDate = null;
/**
* @ORM\Id
* @ORM\GeneratedValue
@@ -28,117 +51,78 @@ class AccompanyingPeriodLocationHistory
/**
* @ORM\ManyToOne(targetEntity=Person::class)
*/
private ?Person $personLocation;
/**
* @ORM\ManyToOne(targetEntity=Address::class)
*/
private ?Address $addressLocation;
private ?Person $personLocation = null;
/**
* @ORM\Column(type="date_immutable")
*/
private ?\DateTimeImmutable $startDate;
private ?DateTimeImmutable $startDate = null;
/**
* @ORM\Column(type="date_immutable")
*/
private ?\DateTimeImmutable $endDate;
/**
* @return int|null
*/
public function getId(): ?int
{
return $this->id;
}
/**
* @return Person|null
*/
public function getPersonLocation(): ?Person
{
return $this->personLocation;
}
/**
* @param Person|null $personLocation
* @return AccompanyingPeriodLocationHistory
*/
public function setPersonLocation(?Person $personLocation): AccompanyingPeriodLocationHistory
{
$this->personLocation = $personLocation;
return $this;
}
/**
* @return Address|null
*/
public function getAddressLocation(): ?Address
{
return $this->addressLocation;
}
/**
* @param Address|null $addressLocation
* @return AccompanyingPeriodLocationHistory
*/
public function setAddressLocation(?Address $addressLocation): AccompanyingPeriodLocationHistory
{
$this->addressLocation = $addressLocation;
return $this;
}
/**
* @return \DateTimeImmutable|null
*/
public function getStartDate(): ?\DateTimeImmutable
{
return $this->startDate;
}
/**
* @param \DateTimeImmutable|null $startDate
* @return AccompanyingPeriodLocationHistory
*/
public function setStartDate(?\DateTimeImmutable $startDate): AccompanyingPeriodLocationHistory
{
$this->startDate = $startDate;
return $this;
}
/**
* @return \DateTimeImmutable|null
*/
public function getEndDate(): ?\DateTimeImmutable
public function getEndDate(): ?DateTimeImmutable
{
return $this->endDate;
}
/**
* @param \DateTimeImmutable|null $endDate
* @return AccompanyingPeriodLocationHistory
*/
public function setEndDate(?\DateTimeImmutable $endDate): AccompanyingPeriodLocationHistory
public function getId(): ?int
{
$this->endDate = $endDate;
return $this;
return $this->id;
}
/**
* @return AccompanyingPeriod
*/
public function getPeriod(): AccompanyingPeriod
{
return $this->period;
}
public function getPersonLocation(): ?Person
{
return $this->personLocation;
}
public function getStartDate(): ?DateTimeImmutable
{
return $this->startDate;
}
public function setAddressLocation(?Address $addressLocation): AccompanyingPeriodLocationHistory
{
$this->addressLocation = $addressLocation;
return $this;
}
public function setEndDate(?DateTimeImmutable $endDate): AccompanyingPeriodLocationHistory
{
$this->endDate = $endDate;
return $this;
}
/**
* @internal use AccompanyingPeriod::addLocationHistory
*/
public function setPeriod(AccompanyingPeriod $period): AccompanyingPeriodLocationHistory
{
$this->period = $period;
return $this;
}
public function setPersonLocation(?Person $personLocation): AccompanyingPeriodLocationHistory
{
$this->personLocation = $personLocation;
return $this;
}
public function setStartDate(?DateTimeImmutable $startDate): AccompanyingPeriodLocationHistory
{
$this->startDate = $startDate;
return $this;
}
}