relation and relationship entities created + endpoints. Still something wrong with link between Relation and Relationship

This commit is contained in:
2021-10-22 19:21:32 +02:00
parent 6ff80be88d
commit 05d16ec9ab
9 changed files with 539 additions and 7 deletions

View File

@@ -0,0 +1,182 @@
<?php
namespace Chill\PersonBundle\Entity\Relationships;
use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\Relationships\Relation;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity()
* @ORM\Table(name="chill_person_relationships")
*/
class Relationship
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"read"})
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Person::class)
* @ORM\JoinColumn(nullable=false)
* @Assert\NotBlank()
* @Groups({"read", "write"})
*/
private $fromPerson;
/**
* @ORM\ManyToOne(targetEntity=Person::class)
* @ORM\JoinColumn(nullable=false)
* @Assert\NotBlank()
* @Groups({"read", "write"})
*/
private $toPerson;
/**
* @ORM\ManyToOne(targetEntity=Relation::class, inversedBy="relationships")
* @ORM\JoinColumn(nullable=false)
* @Assert\NotBlank()
* @Groups({"read", "write"})
*/
private $relation;
/**
* @ORM\Column(type="boolean")
* @Assert\Type(
* type="bool",
* message="This must be of type boolean"
* )
* @Groups({"read"})
*/
private $reverse;
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumn(nullable=false)
*/
private $createdBy;
/**
* @ORM\Column(type="datetime_immutable")
*/
private $createdAt;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*/
private $updatedBy;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
private $updatedAt;
public function getId(): ?int
{
return $this->id;
}
public function getFromPerson(): ?Person
{
return $this->fromPerson;
}
public function setFromPerson(?Person $fromPerson): self
{
$this->fromPerson = $fromPerson;
return $this;
}
public function getToPerson(): ?Person
{
return $this->toPerson;
}
public function setToPerson(?Person $toPerson): self
{
$this->toPerson = $toPerson;
return $this;
}
public function getReverse(): ?bool
{
return $this->reverse;
}
public function setReverse(bool $reverse): self
{
$this->reverse = $reverse;
return $this;
}
public function getCreatedBy(): ?User
{
return $this->createdBy;
}
public function setCreatedBy(?User $createdBy): self
{
$this->createdBy = $createdBy;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedBy(): ?User
{
return $this->updatedBy;
}
public function setUpdatedBy(?User $updatedBy): self
{
$this->updatedBy = $updatedBy;
return $this;
}
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getRelation(): ?Relation
{
return $this->relation;
}
public function setRelation(?Relation $relation): self
{
$this->relation = $relation;
return $this;
}
}