add api for getting goal and results by social action and goal

This commit is contained in:
2021-06-22 16:08:53 +02:00
parent 34d6452286
commit b53f6af8d8
14 changed files with 700 additions and 12 deletions

View File

@@ -38,13 +38,12 @@ use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Column(type="text")
* @Serializer\Groups({"read"})
* @Serializer\Groups({"read", "accompanying_period_work:edit"})
*/
private string $note = "";
/**
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class)
* @Serializer\Groups({"read"})
*/
private ?AccompanyingPeriod $accompanyingPeriod = null;
@@ -83,13 +82,16 @@ use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Column(type="date_immutable")
* @Serializer\Groups({"accompanying_period_work:create"})
* @Serializer\Groups({"accompanying_period_work:edit"})
* @Serializer\Groups({"read"})
*/
private \DateTimeImmutable $startDate;
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default":null})
* @Serializer\Groups({"accompanying_period_work:create", "read"})
* @Serializer\Groups({"accompanying_period_work:create"})
* @Serializer\Groups({"accompanying_period_work:edit"})
* @Serializer\Groups({"read"})
* @Assert\GreaterThan(propertyPath="startDate",
* message="accompanying_course_work.The endDate should be greater than the start date"
* )
@@ -99,6 +101,8 @@ use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\ManyToOne(targetEntity=ThirdParty::class)
* @Serializer\Groups({"read"})
* @Serializer\Groups({"accompanying_period_work:create"})
* @Serializer\Groups({"accompanying_period_work:edit"})
*
* In schema : traitant
*/
@@ -115,13 +119,22 @@ use Symfony\Component\Validator\Constraints as Assert;
private string $createdAutomaticallyReason = "";
/**
* @ORM\OneToMany(targetEntity=AccompanyingPeriodWorkGoal::class, mappedBy="accompanyingPeriodWork")
* @ORM\OneToMany(
* targetEntity=AccompanyingPeriodWorkGoal::class,
* mappedBy="accompanyingPeriodWork",
* cascade={"persist"},
* orphanRemoval=true
* )
* @Serializer\Groups({"read"})
* @Serializer\Groups({"accompanying_period_work:edit"})
*/
private Collection $goals;
/**
* @ORM\ManyToMany(targetEntity=Result::class, inversedBy="accompanyingPeriodWorks")
* @ORM\JoinTable(name="chill_person_accompanying_period_work_result")
* @Serializer\Groups({"read"})
* @Serializer\Groups({"accompanying_period_work:edit"})
*/
private Collection $results;
@@ -130,6 +143,8 @@ use Symfony\Component\Validator\Constraints as Assert;
* @ORM\JoinTable(name="chill_person_accompanying_period_work_third_party")
*
* In schema : intervenants
* @Serializer\Groups({"read"})
* @Serializer\Groups({"accompanying_period_work:edit"})
*/
private Collection $thirdParties;
@@ -255,7 +270,7 @@ use Symfony\Component\Validator\Constraints as Assert;
return $this->endDate;
}
public function setEndDate(\DateTimeInterface $endDate): self
public function setEndDate(?\DateTimeInterface $endDate = null): self
{
$this->endDate = $endDate;
@@ -310,7 +325,7 @@ use Symfony\Component\Validator\Constraints as Assert;
{
if (!$this->goals->contains($goal)) {
$this->goals[] = $goal;
$goal->setAccompanyingPeriodWork2($this);
$goal->setAccompanyingPeriodWork($this);
}
return $this;
@@ -318,10 +333,10 @@ use Symfony\Component\Validator\Constraints as Assert;
public function removeGoal(AccompanyingPeriodWorkGoal $goal): self
{
if ($this->goals->removeElement($goal)) {
if ($this->goals->removeElement($goal)) {
// set the owning side to null (unless already changed)
if ($goal->getAccompanyingPeriodWork2() === $this) {
$goal->setAccompanyingPeriodWork2(null);
if ($goal->getAccompanyingPeriodWork() === $this) {
$goal->setAccompanyingPeriodWork(null);
}
}