mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
GET and POST both working.
This commit is contained in:
@@ -2,50 +2,60 @@
|
||||
|
||||
namespace Chill\PersonBundle\Entity\Relationships;
|
||||
|
||||
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\Relationships\Relation;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
use Doctrine\ORM\Mapping\DiscriminatorColumn;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
* @ORM\Table(name="chill_person_relationships")
|
||||
* @DiscriminatorColumn(name="relation_id", type="integer")
|
||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "relationship"=Relationship::class
|
||||
* })
|
||||
*
|
||||
*/
|
||||
class Relationship
|
||||
class Relationship implements TrackCreationInterface, TrackUpdateInterface
|
||||
{
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
* @ORM\Column(type="integer")
|
||||
* @Groups({"read"})
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private $id;
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Person::class)
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
* @Assert\NotBlank()
|
||||
* @Groups({"read", "write"})
|
||||
* @Assert\NotNull()
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
*/
|
||||
private $fromPerson;
|
||||
private ?Person $fromPerson = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Person::class)
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
* @Assert\NotBlank()
|
||||
* @Groups({"read", "write"})
|
||||
* @Assert\NotNull()
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
*/
|
||||
private $toPerson;
|
||||
private ?Person $toPerson = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Relation::class)
|
||||
* @ORM\JoinColumn(nullable=false, name="relation_id", referencedColumnName="id")
|
||||
* @Assert\NotBlank()
|
||||
* @Groups({"read", "write"})
|
||||
* @Assert\NotNull()
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
*/
|
||||
private $relation;
|
||||
private ?Relation $relation = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
@@ -53,30 +63,30 @@ class Relationship
|
||||
* type="bool",
|
||||
* message="This must be of type boolean"
|
||||
* )
|
||||
* @Groups({"read"})
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
*/
|
||||
private $reverse;
|
||||
private bool $reverse;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private $createdBy;
|
||||
private ?User $createdBy = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable")
|
||||
*/
|
||||
private $createdAt;
|
||||
private ?DateTimeImmutable $createdAt = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
*/
|
||||
private $updatedBy;
|
||||
private ?User $updatedBy = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable", nullable=true)
|
||||
*/
|
||||
private $updatedAt;
|
||||
private ?DateTimeImmutable $updatedAt = null;
|
||||
|
||||
|
||||
public function getId(): ?int
|
||||
@@ -125,9 +135,9 @@ class Relationship
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
||||
public function setCreatedBy(?User $createdBy): self
|
||||
public function setCreatedBy(?User $user): self
|
||||
{
|
||||
$this->createdBy = $createdBy;
|
||||
$this->createdBy = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -137,7 +147,7 @@ class Relationship
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
public function setCreatedAt(\DateTimeImmutable $createdAt): self
|
||||
public function setCreatedAt(\DateTimeInterface $createdAt): self
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
|
||||
@@ -161,7 +171,7 @@ class Relationship
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self
|
||||
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
|
||||
{
|
||||
$this->updatedAt = $updatedAt;
|
||||
|
||||
@@ -179,4 +189,4 @@ class Relationship
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user