src/Entity/Barcode.php line 9

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\BarcodeRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. #[ORM\Entity(repositoryClassBarcodeRepository::class)]
  6. class Barcode
  7. {
  8.     #[ORM\Id]
  9.     #[ORM\GeneratedValue]
  10.     #[ORM\Column]
  11.     private ?int $id null;
  12.     #[ORM\Column(name'code'type'text'nullabletrue)]
  13.     private ?string $code;
  14.     #[ORM\ManyToOne(targetEntity'App\Entity\Products'inversedBy'barcode')]
  15.     private ?Products $products;
  16.     /**
  17.      * @return string|null
  18.      */
  19.     public function getCode(): ?string
  20.     {
  21.         return $this->code;
  22.     }
  23.     /**
  24.      * @param string|null $code
  25.      */
  26.     public function setCode(?string $code): void
  27.     {
  28.         $this->code $code;
  29.     }
  30.     /**
  31.      * @return Products|null
  32.      */
  33.     public function getProducts(): ?Products
  34.     {
  35.         return $this->products;
  36.     }
  37.     /**
  38.      * @param Products|null $products
  39.      */
  40.     public function setProducts(?Products $products): void
  41.     {
  42.         $this->products $products;
  43.     }
  44.     public function getId(): ?int
  45.     {
  46.         return $this->id;
  47.     }
  48.     public function __toString()
  49.     {
  50.         return $this->code//or anything else
  51.     }
  52. }