src/Entity/License.php line 31

Open in your IDE?
  1. <?php
  2. /**
  3.  * @license SILK SOFTWARE HOUSE SP Z O O
  4.  */
  5. namespace App\Entity;
  6. use App\Entity\Admin\Traits\AssignDeviceToCustomerTrait;
  7. use App\Entity\Traits\IdTrait;
  8. use App\Entity\Traits\TimePreUpdateTrait;
  9. use App\Entity\Traits\TimeTrait;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Gedmo\Mapping\Annotation as Gedmo;
  12. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  13. use DateTime;
  14. use Symfony\Component\Validator\Constraints as Assert;
  15. use App\Validator\Constraints as AppAssert;
  16. /**
  17.  * Class Licence.
  18.  *
  19.  * @ORM\Entity(repositoryClass="App\Repository\LicenseRepository")
  20.  * @ORM\Table(name="licences")
  21.  * @ORM\HasLifecycleCallbacks()
  22.  *
  23.  * @Gedmo\SoftDeleteable()
  24.  *
  25.  * @UniqueEntity({"customer", "device"})
  26.  * @UniqueEntity({"licenseNumber"})
  27.  */
  28. class License
  29. {
  30.     use IdTrait;
  31.     use TimeTrait;
  32.     use TimePreUpdateTrait;
  33.     use AssignDeviceToCustomerTrait;
  34.     /**
  35.      * License number.
  36.      *
  37.      * @var string|null
  38.      *
  39.      * @ORM\Column(name="license_number", nullable=true, type="text", options={"comment": "License number."})
  40.      *
  41.      * @Assert\NotBlank()
  42.      */
  43.     private $licenseNumber;
  44.     /**
  45.      * Device.
  46.      *
  47.      * @var Device
  48.      *
  49.      * @Assert\NotBlank()
  50.      *
  51.      * @AppAssert\NewUnique("serialNumber", message="Instrument with serial number #{{fieldValue}} already exists. Please select it from list.")
  52.      *
  53.      * @ORM\ManyToOne(targetEntity="App\Entity\Device", cascade={"persist"})
  54.      * @ORM\JoinColumn(name="device_id", nullable=false)
  55.      */
  56.     private $device;
  57.     /**
  58.      * Customer.
  59.      *
  60.      * @var Customer
  61.      *
  62.      * @Assert\NotBlank()
  63.      *
  64.      * @AppAssert\NewUnique("name", message="Customer named {{fieldValue}} already exists. Please select him from list.")
  65.      *
  66.      * @ORM\ManyToOne(targetEntity="App\Entity\Customer", cascade={"persist"})
  67.      * @ORM\JoinColumn(name="customer_id", nullable=false)
  68.      */
  69.     private $customer;
  70.     /**
  71.      * Licensed from.
  72.      *
  73.      * @var DateTime|null
  74.      *
  75.      * @ORM\Column(name="licensed_from", nullable=true, type="datetime", options={"comment": "When this license starts."})
  76.      */
  77.     private $licensedFrom;
  78.     /**
  79.      * Licensed to.
  80.      *
  81.      * @var DateTime|null
  82.      *
  83.      * @ORM\Column(name="licensed_to", nullable=true, type="datetime", options={"comment": "When this license ends."})
  84.      */
  85.     private $licensedTo;
  86.     /**
  87.      * @var string|null
  88.      *
  89.      * @ORM\Column(name="note", nullable=true, type="text", options={"comment": "Note about customer."})
  90.      */
  91.     private $note;
  92.     /**
  93.      * Get device.
  94.      *
  95.      * @return Device
  96.      */
  97.     public function getDevice(): ?Device
  98.     {
  99.         return $this->device;
  100.     }
  101.     /**
  102.      * Set device.
  103.      *
  104.      * @param Device $device
  105.      *
  106.      * @return License
  107.      */
  108.     public function setDevice(Device $device): License
  109.     {
  110.         $this->device $device;
  111.         return $this;
  112.     }
  113.     /**
  114.      * Get customer.
  115.      *
  116.      * @return Customer
  117.      */
  118.     public function getCustomer(): ?Customer
  119.     {
  120.         return $this->customer;
  121.     }
  122.     /**
  123.      * Set customer.
  124.      *
  125.      * @param Customer $customer
  126.      *
  127.      * @return License
  128.      */
  129.     public function setCustomer(Customer $customer): License
  130.     {
  131.         $this->customer $customer;
  132.         return $this;
  133.     }
  134.     /**
  135.      * Get licensed from.
  136.      *
  137.      * @return DateTime|null
  138.      */
  139.     public function getLicensedFrom(): ?DateTime
  140.     {
  141.         return $this->licensedFrom;
  142.     }
  143.     /**
  144.      * Set licensed from.
  145.      *
  146.      * @param DateTime|null $licensedFrom
  147.      *
  148.      * @return License
  149.      */
  150.     public function setLicensedFrom(?DateTime $licensedFrom): License
  151.     {
  152.         $this->licensedFrom $licensedFrom;
  153.         return $this;
  154.     }
  155.     /**
  156.      * Get licensed to.
  157.      *
  158.      * @return DateTime|null
  159.      */
  160.     public function getLicensedTo(): ?DateTime
  161.     {
  162.         return $this->licensedTo;
  163.     }
  164.     /**
  165.      * Set licensed to.
  166.      *
  167.      * @param DateTime|null $licensedTo
  168.      *
  169.      * @return License
  170.      */
  171.     public function setLicensedTo(?DateTime $licensedTo): License
  172.     {
  173.         $this->licensedTo $licensedTo;
  174.         return $this;
  175.     }
  176.     /**
  177.      * Get note.
  178.      *
  179.      * @return string|null
  180.      */
  181.     public function getNote(): ?string
  182.     {
  183.         return $this->note;
  184.     }
  185.     /**
  186.      * Set note.
  187.      *
  188.      * @param string|null $note
  189.      *
  190.      * @return License
  191.      */
  192.     public function setNote(?string $note): License
  193.     {
  194.         $this->note $note;
  195.         return $this;
  196.     }
  197.     /**
  198.      * Get license number.
  199.      *
  200.      * @return string|null
  201.      */
  202.     public function getLicenseNumber(): ?string
  203.     {
  204.         return $this->licenseNumber;
  205.     }
  206.     /**
  207.      * Set license number.
  208.      *
  209.      * @param string|null $licenseNumber
  210.      *
  211.      * @return License
  212.      */
  213.     public function setLicenseNumber(?string $licenseNumber): License
  214.     {
  215.         $this->licenseNumber $licenseNumber;
  216.         return $this;
  217.     }
  218. }