src/Entity/District.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\TimeStampable;
  4. use App\Repository\DistrictRepository;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use App\Entity\Traits\TimeStampableTrait;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. #[ORM\Entity(repositoryClass: DistrictRepository::class)]
  11. #[ORM\HasLifecycleCallbacks]
  12. class District
  13. {
  14.     use TimeStampable;
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column]
  18.     #[Groups(["entity:write"])]
  19.     private ?int $id = null;
  20.     #[ORM\Column(length: 45)]
  21.     #[Groups(["entity:write"])]
  22.     #[Assert\NotBlank(message: 'Le nom du quartier est obligatoire.')]
  23.     private ?string $name = null;
  24.     #[ORM\Column(type: 'decimal', precision: 10, scale: 8, nullable: true)]
  25.     private ?string $latitude;
  26.     #[ORM\Column(type: Types::DECIMAL, precision: 10, scale: 8, nullable: true)]
  27.     private ?string $longitude = null;
  28.     #[ORM\ManyToOne(inversedBy: 'districts')]
  29.     #[Assert\NotBlank(message: 'Le nom de la commune est obligatoire.')]
  30.     private ?Municipality $municipality = null;
  31.     #[ORM\ManyToOne]
  32.     private ?User $createdBy = null;
  33.     public function __construct()
  34.     {
  35.         $this->createdAt = new \DateTimeImmutable();
  36.         $this->updatedAt = new \DateTimeImmutable();
  37.     }
  38.     public function getId(): ?int
  39.     {
  40.         return $this->id;
  41.     }
  42.     public function getName(): ?string
  43.     {
  44.         return $this->name;
  45.     }
  46.     public function setName(string $name): self
  47.     {
  48.         $this->name = $name;
  49.         return $this;
  50.     }
  51.     public function getLatitude(): ?string
  52.     {
  53.         return $this->latitude;
  54.     }
  55.     public function setLatitude(?string $latitude): self
  56.     {
  57.         $this->latitude = $latitude;
  58.         return $this;
  59.     }
  60.     public function getLongitude(): ?string
  61.     {
  62.         return $this->longitude;
  63.     }
  64.     public function setLongitude(?string $longitude): self
  65.     {
  66.         $this->longitude = $longitude;
  67.         return $this;
  68.     }
  69.     public function getMunicipality(): ?Municipality
  70.     {
  71.         return $this->municipality;
  72.     }
  73.     public function setMunicipality(?Municipality $municipality): self
  74.     {
  75.         $this->municipality = $municipality;
  76.         return $this;
  77.     }
  78.     public function getCreatedBy(): ?User
  79.     {
  80.         return $this->createdBy;
  81.     }
  82.     public function setCreatedBy(?User $createdBy): self
  83.     {
  84.         $this->createdBy = $createdBy;
  85.         return $this;
  86.     }
  87. }