src/Entity/UserRegion.php line 11

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRegionRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Gedmo\Timestampable\Traits\TimestampableEntity;
  7. #[ORM\Entity(repositoryClassUserRegionRepository::class)]
  8. class UserRegion
  9. {
  10.     use TimestampableEntity;
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\ManyToOne(inversedBy'userRegions')]
  16.     private ?User $user null;
  17.     #[ORM\ManyToOne(inversedBy'userRegions')]
  18.     private ?Region $region null;
  19.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  20.     private ?\DateTimeInterface $startDate null;
  21.     public function getId(): ?int
  22.     {
  23.         return $this->id;
  24.     }
  25.     public function getUser(): ?User
  26.     {
  27.         return $this->user;
  28.     }
  29.     public function setUser(?User $user): static
  30.     {
  31.         $this->user $user;
  32.         return $this;
  33.     }
  34.     public function getRegion(): ?Region
  35.     {
  36.         return $this->region;
  37.     }
  38.     public function setRegion(?Region $region): static
  39.     {
  40.         $this->region $region;
  41.         return $this;
  42.     }
  43.     public function getStartDate(): ?\DateTimeInterface
  44.     {
  45.         return $this->startDate;
  46.     }
  47.     public function setStartDate(?\DateTimeInterface $startDate): static
  48.     {
  49.         $this->startDate $startDate;
  50.         return $this;
  51.     }
  52.     // to string
  53.     public function __toString()
  54.     {
  55.         return $this->getRegion() ? $this->getRegion()->getName() : '';
  56.     }
  57. }