src/Entity/Department.php line 41
<?phpnamespace App\Entity;use ApiPlatform\Metadata\ApiResource;use ApiPlatform\Metadata\GetCollection;use ApiPlatform\Metadata\Get;use App\Controller\Api\Establishment\ApiEstablishmentGetByUserController;use App\Model\Wallet\WalletInterface;use App\Repository\DepartmentRepository;use App\State\User\UserEstablishmentDepartementsProvider;use App\Trait\ActivableTrait;use App\Trait\AuthorTrait;use App\Trait\CurrentStateTrait;use App\Trait\DateTrait;use App\Trait\DeletableTrait;use App\Trait\WalletTrait;use DateTimeImmutable;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Serializer\Annotation\Groups;#[ORM\Entity(repositoryClass: DepartmentRepository::class)]#[ApiResource(operations: [new GetCollection(normalizationContext: ['groups' => ['department:list']]),new Get(),new GetCollection(uriTemplate: 'user/establishments/departments',normalizationContext: ['groups' => ['department:list']],provider: UserEstablishmentDepartementsProvider::class),],normalizationContext: ['groups' => ['department:list', 'department:view']])]class Department implements WalletInterface{use DateTrait {DateTrait::__construct as private dateConstruct;}use ActivableTrait;use CurrentStateTrait;use DeletableTrait;use WalletTrait;use AuthorTrait;#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]#[Groups(['department:list', 'article:list', 'order:list'])]private ?int $id = null;#[ORM\Column(length: 255)]#[Groups(['department:list', 'department:new', 'article:list', 'order:list'])]private ?string $name = null;#[ORM\Column(type: Types::TEXT)]#[Groups(['department:view', 'department:new'])]private ?string $content = null;#[ORM\Column(type: "smallint", options: ["defaults" => 0])]#[Groups(['department:list', 'department:view'])]private ?int $level = 0;#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'departments')]#[Groups(['department:list', 'department:new'])]private ?self $parent = null;#[ORM\ManyToOne(inversedBy: 'departments')]#[ORM\JoinColumn(nullable: false)]private ?Establishment $establishment = null;#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)]#[Groups(['department:view'])]private Collection $departments;#[ORM\OneToMany(mappedBy: 'department', targetEntity: Collections::class)]private Collection $collections;#[ORM\OneToMany(mappedBy: 'department', targetEntity: Order::class, orphanRemoval: true)]private Collection $orders;#[ORM\OneToMany(mappedBy: 'department', targetEntity: Client::class)]private Collection $clients;#[ORM\OneToMany(mappedBy: 'department', targetEntity: Employee::class)]private Collection $employees;#[ORM\OneToMany(mappedBy: 'department', targetEntity: ArticleDepartment::class, orphanRemoval: true)]private Collection $articles;#[ORM\Column]#[Groups(['department:new'])]private ?bool $isBookable = null;#[ORM\Column]#[Groups(['department:new'])]private ?bool $hasWallets = null;#[ORM\OneToMany(mappedBy: 'department', targetEntity: Lot::class)]private Collection $lots;#[ORM\Column]#[Groups(['department:new'])]private ?bool $isOnMenu = false;#[ORM\Column(length: 255, nullable: true)]#[Groups(['department:new'])]private ?string $onMenu = null;#[ORM\ManyToMany(targetEntity: Planning::class, mappedBy: 'departments')]private Collection $plannings;public function __construct(){$this->currentState = 'draft';$this->dateConstruct();$this->departments = new ArrayCollection();$this->orders = new ArrayCollection();$this->clients = new ArrayCollection();$this->employees = new ArrayCollection();$this->articles = new ArrayCollection();$this->lots = new ArrayCollection();}public function getId(): ?int{return $this->id;}public function getName(): ?string{return $this->name;}public function setName(string $name): self{$this->name = $name;return $this;}public function getContent(): ?string{return $this->content;}public function setContent(string $content): self{$this->content = $content;return $this;}public function getLevel(): ?int{return $this->level;}public function setLevel(int $level): self{$this->level = $level;return $this;}public function getParent(): ?self{return $this->parent;}public function setParent(?self $parent): self{$this->parent = $parent;return $this;}public function getEstablishment(): ?Establishment{return $this->establishment;}public function setEstablishment(?Establishment $establishment): self{$this->establishment = $establishment;return $this;}/*** @return Collection<int, self>*/public function getDepartments(): Collection{return $this->departments;}public function addDepartment(self $department): self{if (!$this->departments->contains($department)) {$this->departments->add($department);$department->setParent($this);}return $this;}public function removeDepartment(self $department): self{if ($this->departments->removeElement($department)) {// set the owning side to null (unless already changed)if ($department->getParent() === $this) {$department->setParent(null);}}return $this;}/*** @return Collection<int, Order>*/public function getOrders(): Collection{return $this->orders;}public function addOrder(Order $order): self{if (!$this->orders->contains($order)) {$this->orders->add($order);$order->setDepartment($this);}return $this;}public function removeOrder(Order $order): self{if ($this->orders->removeElement($order)) {// set the owning side to null (unless already changed)if ($order->getDepartment() === $this) {$order->setDepartment(null);}}return $this;}/*** @return Collection<int, Client>*/public function getClients(): Collection{return $this->clients;}public function addClient(Client $client): self{if (!$this->clients->contains($client)) {$this->clients->add($client);$client->setDepartment($this);}return $this;}public function removeClient(Client $client): self{if ($this->clients->removeElement($client)) {// set the owning side to null (unless already changed)if ($client->getDepartment() === $this) {$client->setDepartment(null);}}return $this;}/*** @return Collection<int, Employee>*/public function getEmployees(): Collection{return $this->employees;}public function addEmployee(Employee $employee): self{if (!$this->employees->contains($employee)) {$this->employees->add($employee);$employee->setDepartment($this);}return $this;}public function removeEmployee(Employee $employee): self{if ($this->employees->removeElement($employee)) {// set the owning side to null (unless already changed)if ($employee->getDepartment() === $this) {$employee->setDepartment(null);}}return $this;}/*** @return Collection<int, ArticleDepartment>*/public function getArticles(): Collection{return $this->articles;}public function addArticle(ArticleDepartment $article): self{if (!$this->articles->contains($article)) {$this->articles->add($article);$article->setDepartment($this);}return $this;}public function removeArticle(ArticleDepartment $article): self{if ($this->articles->removeElement($article)) {// set the owning side to null (unless already changed)if ($article->getDepartment() === $this) {$article->setDepartment(null);}}return $this;}public function __serialize(): array{return [$this->id, $this->name];}public function __unserialize(array $data): void{if (count($data) === 4) [$this->id, $this->name] = $data;}public function isIsBookable(): ?bool{return $this->isBookable;}public function setIsBookable(bool $isBookable): self{$this->isBookable = $isBookable;return $this;}public function isHasWallets(): ?bool{return $this->hasWallets;}public function setHasWallets(bool $hasWallets): self{$this->hasWallets = $hasWallets;return $this;}/*** @return Collection<int, Lot>*/public function getLots(): Collection{return $this->lots;}public function addLot(Lot $lot): self{if (!$this->lots->contains($lot)) {$this->lots->add($lot);$lot->setDepartment($this);}return $this;}public function removeLot(Lot $lot): self{if ($this->lots->removeElement($lot)) {// set the owning side to null (unless already changed)if ($lot->getDepartment() === $this) {$lot->setDepartment(null);}}return $this;}public function isIsOnMenu(): ?bool{return $this->isOnMenu;}public function setIsOnMenu(bool $isOnMenu): self{$this->isOnMenu = $isOnMenu;return $this;}public function getOnMenu(): ?string{return $this->onMenu;}public function setOnMenu(?string $onMenu): self{$this->onMenu = $onMenu;return $this;}public function increaseLevel(?int $param){}/*** @return Collection<int, Planning>*/public function getPlannings(): Collection{return $this->plannings;}public function addPlanning(Planning $planning): static{if (!$this->plannings->contains($planning)) {$this->plannings->add($planning);$planning->addDepartment($this);}return $this;}public function removePlanning(Planning $planning): static{if ($this->plannings->removeElement($planning)) {$planning->removeDepartment($this);}return $this;}public function __toString(): string{$departmentParent = $this->getParent();$departmentParent = $departmentParent ? " [$departmentParent]" : "";return $this->name . $departmentParent;}}