src/Entity/Printer/Printer.php line 17

  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Printer;
  4. use App\Entity\IdentifiableTrait;
  5. use App\Entity\User\AdminUser;
  6. use App\Repository\Printer\PrinterRepository;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Sylius\Component\Resource\Model\ResourceInterface;
  11. #[ORM\Entity(repositoryClass: PrinterRepository::class)]
  12. #[ORM\Table(name: 'app_printer')]
  13. class Printer implements ResourceInterface
  14. {
  15.     use IdentifiableTrait;
  16.     #[ORM\Column(length: 255)]
  17.     private string $name = '';
  18.     #[ORM\OneToOne(targetEntity: AdminUser::class, cascade: ['persist'])]
  19.     #[ORM\JoinColumn(name: 'admin_user_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')]
  20.     private AdminUser $adminUser;
  21.     #[ORM\Column(type: 'boolean', options: ['default' => true])]
  22.     private bool $enabled = true;
  23.     /** @var Collection<int, \App\Entity\Order\Order> */
  24.     #[ORM\OneToMany(mappedBy: 'printer', targetEntity: \App\Entity\Order\Order::class)]
  25.     private Collection $orders;
  26.     public function __construct()
  27.     {
  28.         $this->orders = new ArrayCollection();
  29.     }
  30.     public function getName(): string
  31.     {
  32.         return $this->name;
  33.     }
  34.     public function setName(string $name): self
  35.     {
  36.         $this->name = $name;
  37.         return $this;
  38.     }
  39.     public function getAdminUser(): AdminUser
  40.     {
  41.         return $this->adminUser;
  42.     }
  43.     public function setAdminUser(AdminUser $adminUser): self
  44.     {
  45.         $this->adminUser = $adminUser;
  46.         return $this;
  47.     }
  48.     public function isEnabled(): bool
  49.     {
  50.         return $this->enabled;
  51.     }
  52.     public function setEnabled(bool $enabled): self
  53.     {
  54.         $this->enabled = $enabled;
  55.         return $this;
  56.     }
  57.     /** @return Collection<int, \App\Entity\Order\Order> */
  58.     public function getOrders(): Collection
  59.     {
  60.         return $this->orders;
  61.     }
  62.     public function __toString(): string
  63.     {
  64.         return $this->name;
  65.     }
  66. }