add groups on household serialization

This commit is contained in:
2021-06-02 21:44:49 +02:00
parent 261acdfd24
commit e9caa7b4b8
4 changed files with 67 additions and 10 deletions

View File

@@ -6,6 +6,7 @@ use Doctrine\ORM\Mapping as ORM;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\Household\Household;
use Chill\PersonBundle\Entity\Household\Position;
use Symfony\Component\Serializer\Annotation as Serializer;
/**
@@ -20,26 +21,31 @@ class HouseholdMember
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Serializer\Groups({"read"})
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Position::class)
* @Serializer\Groups({"read"})
*/
private ?Position $position = null;
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
* @Serializer\Groups({"read"})
*/
private ?\DateTimeImmutable $startDate = null;
/**
* @ORM\Column(type="date_immutable", nullable= true, options={"default": null})
* @Serializer\Groups({"read"})
*/
private ?\DateTimeImmutable $endDate = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Serializer\Groups({"read"})
*/
private ?string $comment = NULL;
@@ -50,6 +56,7 @@ class HouseholdMember
/**
* @ORM\Column(type="boolean", options={"default": false})
* @Serializer\Groups({"read"})
*/
private bool $holder = false;
@@ -59,6 +66,7 @@ class HouseholdMember
* @ORM\ManyToOne(
* targetEntity="\Chill\PersonBundle\Entity\Person"
* )
* @Serializer\Groups({"read"})
*/
private ?Person $person = null;
@@ -131,6 +139,9 @@ class HouseholdMember
return $this;
}
/**
* @Serializer\Groups({"read"})
*/
public function getShareHousehold(): ?bool
{
return $this->sharedHousehold;