src/Entity/SupplierHoliday.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Validator\Constraints as AppAssert;
  4. use DateTime;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. /**
  9.  * @ORM\Entity(repositoryClass="App\Repository\SupplierHolidayRepository")
  10.  * @ORM\Table(name="malys_supplier_holiday")
  11.  * @ORM\HasLifecycleCallbacks()
  12.  * @UniqueEntity (fields={"supplier", "code"}, errorPath="code", message="Vous avez déjà ce code date pour ce fournisseur")
  13.  */
  14. class SupplierHoliday
  15. {
  16.     /**
  17.      * @var integer
  18.      *
  19.      * @ORM\Column(name="id", type="integer")
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue(strategy="AUTO")
  22.      */
  23.     protected $id;
  24.     /**
  25.      * @ORM\Column(name="code", type="string", nullable=false)
  26.      * @AppAssert\DateCode()
  27.      * @Assert\NotBlank
  28.      */
  29.     protected $code;
  30.     /**
  31.      * @ORM\Column(name="label", type="string", nullable=false)
  32.      * @Assert\NotBlank
  33.      * @Assert\Length (max=15)
  34.      */
  35.     protected $label;
  36.     /**
  37.      * @ORM\ManyToOne(targetEntity="App\Entity\Supplier", inversedBy="holidays", fetch="EAGER")
  38.      * @ORM\JoinColumn(name="supplier_id", referencedColumnName="id", nullable=false)
  39.      * @Assert\NotBlank
  40.      */
  41.     public $supplier;
  42.     /**
  43.      * @var DateTime
  44.      *
  45.      * @ORM\Column(name="createdAt", type="datetime", nullable=false)
  46.      */
  47.     protected $createdAt;
  48.     /**
  49.      *
  50.      * @var DateTime
  51.      *
  52.      * @ORM\Column(name="updatedAt", type="datetime", nullable=true)
  53.      */
  54.     protected $updatedAt;
  55.     /**
  56.      * @var boolean
  57.      *
  58.      * @ORM\Column(name="not_delivering_orders", type="boolean", options={"default" : true})
  59.      */
  60.     protected $notDeliveringOrders true;
  61.     /**
  62.      * @var boolean
  63.      *
  64.      * @ORM\Column(name="not_reading_orders", type="boolean", options={"default" : true})
  65.      */
  66.     protected $notReadingOrders true;
  67.     public function __toString()
  68.     {
  69.         return $this->supplier->getCompanyName() . ' - ' $this->code;
  70.     }
  71.     /**
  72.      * @return int
  73.      */
  74.     public function getId(): ?int
  75.     {
  76.         return $this->id;
  77.     }
  78.     /**
  79.      * @return mixed
  80.      */
  81.     public function getCode()
  82.     {
  83.         return $this->code;
  84.     }
  85.     /**
  86.      * @param mixed $code
  87.      */
  88.     public function setCode($code): void
  89.     {
  90.         $this->code $code;
  91.     }
  92.     /**
  93.      * @return mixed
  94.      */
  95.     public function getLabel()
  96.     {
  97.         return $this->label;
  98.     }
  99.     /**
  100.      * @param mixed $label
  101.      */
  102.     public function setLabel($label): void
  103.     {
  104.         $this->label $label;
  105.     }
  106.     /**
  107.      * @return mixed
  108.      */
  109.     public function getSupplier()
  110.     {
  111.         return $this->supplier;
  112.     }
  113.     /**
  114.      * @param mixed $supplier
  115.      */
  116.     public function setSupplier($supplier): void
  117.     {
  118.         $this->supplier $supplier;
  119.     }
  120.     /**
  121.      * @return DateTime
  122.      */
  123.     public function getCreatedAt(): DateTime
  124.     {
  125.         return $this->createdAt;
  126.     }
  127.     /**
  128.      * Set createdAt
  129.      * @ORM\PrePersist
  130.      */
  131.     public function setCreatedAt()
  132.     {
  133.         $this->createdAt = new DateTime();
  134.         $this->updatedAt = new DateTime();
  135.         return $this;
  136.     }
  137.     /**
  138.      * @return DateTime
  139.      */
  140.     public function getUpdatedAt(): DateTime
  141.     {
  142.         return $this->updatedAt;
  143.     }
  144.     /**
  145.      * Set updatedAt
  146.      * @ORM\PreUpdate
  147.      */
  148.     public function setUpdatedAt()
  149.     {
  150.         $this->updatedAt = new DateTime();
  151.         return $this;
  152.     }
  153.     /**
  154.      * @return bool
  155.      */
  156.     public function isNotDeliveringOrders(): bool
  157.     {
  158.         return $this->notDeliveringOrders;
  159.     }
  160.     /**
  161.      * @param bool $notDeliveringOrders
  162.      */
  163.     public function setNotDeliveringOrders(bool $notDeliveringOrders): void
  164.     {
  165.         $this->notDeliveringOrders $notDeliveringOrders;
  166.     }
  167.     /**
  168.      * @return bool
  169.      */
  170.     public function isNotReadingOrders(): bool
  171.     {
  172.         return $this->notReadingOrders;
  173.     }
  174.     /**
  175.      * @param bool $notReadingOrders
  176.      */
  177.     public function setNotReadingOrders(bool $notReadingOrders): void
  178.     {
  179.         $this->notReadingOrders $notReadingOrders;
  180.     }
  181. }