src/Entity/PointOfSale.php line 21

Open in your IDE?
  1. <?php
  2.     namespace App\Entity;
  3.     use App\Repository\PointOfSaleRepository;
  4.     use Doctrine\Common\Collections\ArrayCollection;
  5.     use Doctrine\Common\Collections\Collection;
  6.     use Doctrine\ORM\Mapping as ORM;
  7.     use JMS\Serializer\Annotation as Serializer;
  8.     use JMS\Serializer\Annotation\Expose;
  9.     use JMS\Serializer\Annotation\Groups;
  10.     use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  11.     /**
  12.      * @ORM\Entity(repositoryClass=PointOfSaleRepository::class)
  13.      *
  14.      * @UniqueEntity("code")
  15.      *
  16.      * @Serializer\ExclusionPolicy("ALL")
  17.      */
  18.     class PointOfSale
  19.     {
  20.         /**
  21.          * Identifiant unique
  22.          *
  23.          * @ORM\Id
  24.          * @ORM\GeneratedValue
  25.          * @ORM\Column(type="integer")
  26.          *
  27.          * @Expose
  28.          * @Groups({"export_point_of_sale_datatable", "point_of_sale","point_sale"})
  29.          */
  30.         private ?int $id NULL;
  31.         /**
  32.          * Code
  33.          *
  34.          * @ORM\Column(type="string", length=10, unique=true)
  35.          *
  36.          * @Expose
  37.          * @Groups({"export_point_of_sale_datatable", "point_of_sale", "user"})
  38.          */
  39.         private ?string $code NULL;
  40.         /**
  41.          * Nom
  42.          *
  43.          * @ORM\Column(type="string", length=255)
  44.          *
  45.          * @Expose
  46.          * @Groups({"export_point_of_sale_datatable", "point_of_sale", "user"})
  47.          */
  48.         private ?string $name NULL;
  49.         /**
  50.          * Ville
  51.          *
  52.          * @ORM\Column(type="string", length=255)
  53.          *
  54.          * @Expose
  55.          * @Groups({ "export_point_of_sale_datatable", "point_of_sale", "user"})
  56.          */
  57.         private ?string $city NULL;
  58.         /**
  59.          * Actif / Inactif
  60.          *
  61.          * @ORM\Column(type="boolean", options={"default":true})
  62.          *
  63.          * @Expose
  64.          * @Groups({ "export_point_of_sale_datatable", "point_of_sale"})
  65.          */
  66.         private ?bool $enabled TRUE;
  67.         /**
  68.          * Utilisateur dans le point de vente
  69.          *
  70.          * @ORM\OneToMany(targetEntity=User::class, mappedBy="pointOfSale")
  71.          * @Expose
  72.          * @Groups({"point_of_sale"})
  73.          */
  74.         private Collection $users;
  75.         /**
  76.          * Utilisateurs qui gèrent le point de vente
  77.          *
  78.          * @ORM\ManyToMany(targetEntity=User::class, inversedBy="managedPointOfSales")
  79.          */
  80.         private Collection $managers;
  81.         /**
  82.          * @ORM\ManyToOne(targetEntity=User::class, inversedBy="createdPointOfSales")
  83.          *
  84.          * @Expose
  85.          * @Groups({"point_of_sale"})
  86.          */
  87.         private ?User $createdBy NULL;
  88.         /**
  89.          * @ORM\OneToOne(targetEntity=PointOfSaleAddress::class, cascade={"persist", "remove"})
  90.          */
  91.         private ?PointOfSaleAddress $address NULL;
  92.         public function __construct()
  93.         {
  94.             $this->users    = new ArrayCollection();
  95.             $this->managers = new ArrayCollection();
  96.         }
  97.         public function __toString()
  98.         {
  99.             return $this->getCode();
  100.         }
  101.         public function getId(): ?int
  102.         {
  103.             return $this->id;
  104.         }
  105.         public function getCode(): ?string
  106.         {
  107.             return $this->code;
  108.         }
  109.         public function setCode(string $code): self
  110.         {
  111.             $this->code $code;
  112.             return $this;
  113.         }
  114.         public function getName(): ?string
  115.         {
  116.             return $this->name;
  117.         }
  118.         public function setName(string $name): self
  119.         {
  120.             $this->name $name;
  121.             return $this;
  122.         }
  123.         public function getCity(): ?string
  124.         {
  125.             return $this->city;
  126.         }
  127.         public function setCity(string $city): self
  128.         {
  129.             $this->city $city;
  130.             return $this;
  131.         }
  132.         /**
  133.          * @return Collection<int, User>
  134.          */
  135.         public function getUsers(): Collection
  136.         {
  137.             return $this->users;
  138.         }
  139.         public function addUser(User $user): self
  140.         {
  141.             if (!$this->users->contains($user)) {
  142.                 $this->users[] = $user;
  143.                 $user->setPointOfSale($this);
  144.             }
  145.             return $this;
  146.         }
  147.         public function removeUser(User $user): self
  148.         {
  149.             if ($this->users->removeElement($user)) {
  150.                 // set the owning side to null (unless already changed)
  151.                 if ($user->getPointOfSale() === $this) {
  152.                     $user->setPointOfSale(NULL);
  153.                 }
  154.             }
  155.             return $this;
  156.         }
  157.         public function isEnabled(): ?bool
  158.         {
  159.             return $this->enabled;
  160.         }
  161.         public function setEnabled(bool $enabled): self
  162.         {
  163.             $this->enabled $enabled;
  164.             return $this;
  165.         }
  166.         /**
  167.          * @return Collection<int, User>
  168.          */
  169.         public function getManagers(): Collection
  170.         {
  171.             return $this->managers;
  172.         }
  173.         public function addManager(User $manager): self
  174.         {
  175.             if (!$this->managers->contains($manager)) {
  176.                 $this->managers[] = $manager;
  177.             }
  178.             return $this;
  179.         }
  180.         public function removeManager(User $manager): self
  181.         {
  182.             $this->managers->removeElement($manager);
  183.             return $this;
  184.         }
  185.         public function getCreatedBy(): ?User
  186.         {
  187.             return $this->createdBy;
  188.         }
  189.         public function setCreatedBy(?User $createdBy): self
  190.         {
  191.             $this->createdBy $createdBy;
  192.             return $this;
  193.         }
  194.         public function getAddress(): ?PointOfSaleAddress
  195.         {
  196.             return $this->address;
  197.         }
  198.         public function setAddress(?PointOfSaleAddress $address): self
  199.         {
  200.             $this->address $address;
  201.             return $this;
  202.         }
  203.     }