src/Entity/SupplierCustomer.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use DateTime;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Doctrine\ORM\Mapping\UniqueConstraint;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. /**
  9.  * Class SupplierCustomer
  10.  *
  11.  * @ORM\Entity
  12.  * @ORM\Table(name="malys_supplier_customer", uniqueConstraints={@UniqueConstraint(name="unique_couple", columns={"customer_id", "supplier_id"})})
  13.  * @ORM\HasLifecycleCallbacks()
  14.  * @ORM\Entity(repositoryClass="App\Repository\SupplierCustomerRepository")
  15.  * @UniqueEntity(
  16.  *     fields={"customer", "supplier"},
  17.  *     message="Vous avez déjà un compte chez fournisseur",
  18.  *     groups={"front", "bo_full", "bo_init", "Default"}
  19.  * )
  20.  * @package App\Entity
  21.  *
  22.  */
  23. class SupplierCustomer
  24. {
  25.     /**
  26.      * @var integer
  27.      *
  28.      * @ORM\Column(name="id", type="integer")
  29.      * @ORM\Id
  30.      * @ORM\GeneratedValue(strategy="AUTO")
  31.      */
  32.     protected $id;
  33.     /**
  34.      * @var string
  35.      *
  36.      * @ORM\Column(name="adherent_number", type="string", length=255, nullable=true)
  37.      * @Assert\NotBlank(message="Merci d'indiquer votre n° client", groups={"front", "bo_full", "Default"})
  38.      */
  39.     protected $adherentNumber;
  40.     /**
  41.      * @var Customer
  42.      * @ORM\ManyToOne(targetEntity="Customer", inversedBy="supplierCustomers")
  43.      * @ORM\JoinColumn(name="customer_id", referencedColumnName="id")
  44.      */
  45.     protected $customer;
  46.     /**
  47.      * @var Supplier
  48.      *
  49.      * @ORM\ManyToOne(targetEntity="Supplier", inversedBy="customers")
  50.      * @ORM\JoinColumn(name="supplier_id", referencedColumnName="id", onDelete="CASCADE")
  51.      */
  52.     protected $supplier;
  53.     /**
  54.      * @var string
  55.      *
  56.      * @ORM\Column(name="column_price", type="string", length=255, nullable=false)
  57.      * @Assert\NotBlank (groups={"bo_full"})
  58.      */
  59.     protected $columnPrice;
  60.     /**
  61.      * @var DeliveryModel
  62.      *
  63.      * @ORM\ManyToOne(targetEntity="DeliveryModel", cascade={"persist"}, inversedBy="supplierCustomerLinks")
  64.      * @ORM\JoinColumn(name="delivery_model_id", referencedColumnName="id")
  65.      * @Assert\NotBlank (groups={"bo_full"})
  66.      */
  67.     protected $deliveryModel;
  68.     /**
  69.      * @var DateTime
  70.      *
  71.      * @ORM\Column(name="createdAt", type="datetime", nullable=false)
  72.      */
  73.     protected $createdAt;
  74.     /**
  75.      * @var DateTime
  76.      *
  77.      * @ORM\Column(name="updatedAt", type="datetime", nullable=true)
  78.      */
  79.     protected $updatedAt;
  80.     /**
  81.      * @ORM\ManyToOne(targetEntity="App\Entity\User")
  82.      * @ORM\JoinColumn(name="saleperson_id", referencedColumnName="id", nullable=true)
  83.      */
  84.     protected $salePerson;
  85.     /**
  86.      * @var boolean
  87.      *
  88.      * @ORM\Column(name="legacy_link", type="boolean", options={"default" : false}, nullable=true)
  89.      */
  90.     protected $legacyLink false;
  91.     /**
  92.      * SupplierCustomer constructor.
  93.      */
  94.     public function __construct()
  95.     {
  96.     }
  97.     public function __toString()
  98.     {
  99.         $suppName $this->getSupplier()->getCompanyName();
  100.         $shopName $this->getCustomer()->getBrandName();
  101.         return $shopName ' <> ' $suppName;
  102.     }
  103.     /**
  104.      * @return int
  105.      */
  106.     public function getId()
  107.     {
  108.         return $this->id;
  109.     }
  110.     /**
  111.      * @param int $id
  112.      */
  113.     public function setId($id)
  114.     {
  115.         $this->id $id;
  116.     }
  117.     /**
  118.      * @return string
  119.      */
  120.     public function getAdherentNumber()
  121.     {
  122.         return $this->adherentNumber;
  123.     }
  124.     /**
  125.      * @param string $adherentNumber
  126.      */
  127.     public function setAdherentNumber($adherentNumber)
  128.     {
  129.         $this->adherentNumber $adherentNumber;
  130.     }
  131.     /**
  132.      * @return Customer
  133.      */
  134.     public function getCustomer()
  135.     {
  136.         return $this->customer;
  137.     }
  138.     /**
  139.      * @param Customer $customer
  140.      */
  141.     public function setCustomer($customer)
  142.     {
  143.         $this->customer $customer;
  144.     }
  145.     /**
  146.      * @return Supplier
  147.      */
  148.     public function getSupplier()
  149.     {
  150.         return $this->supplier;
  151.     }
  152.     /**
  153.      * @param Supplier $supplier
  154.      */
  155.     public function setSupplier($supplier)
  156.     {
  157.         $this->supplier $supplier;
  158.     }
  159.     /**
  160.      * @return string
  161.      */
  162.     public function getColumnPrice()
  163.     {
  164.         return $this->columnPrice;
  165.     }
  166.     /**
  167.      * @param string $columnPrice
  168.      */
  169.     public function setColumnPrice($columnPrice)
  170.     {
  171.         $this->columnPrice $columnPrice;
  172.     }
  173.     /**
  174.      * @return DeliveryModel
  175.      */
  176.     public function getDeliveryModel()
  177.     {
  178.         return $this->deliveryModel;
  179.     }
  180.     /**
  181.      * @param DeliveryModel $deliveryModel
  182.      */
  183.     public function setDeliveryModel($deliveryModel)
  184.     {
  185.         $this->deliveryModel $deliveryModel;
  186.     }
  187.     /**
  188.      * @return DateTime
  189.      */
  190.     public function getCreatedAt()
  191.     {
  192.         return $this->createdAt;
  193.     }
  194.     /**
  195.      *
  196.      * @return SupplierCustomer
  197.      * @ORM\PrePersist
  198.      */
  199.     public function prePersist()
  200.     {
  201.         $this->createdAt = new DateTime();
  202.         $this->updatedAt = new DateTime();
  203.         return $this;
  204.     }
  205.     public function setCreatedAt(DateTime $dt)
  206.     {
  207.         $this->createdAt $dt;
  208.     }
  209.     /**
  210.      * @return DateTime
  211.      */
  212.     public function getUpdatedAt()
  213.     {
  214.         return $this->updatedAt;
  215.     }
  216.     /**
  217.      * Set updatedAt
  218.      *
  219.      * @return SupplierCustomer
  220.      * @ORM\PreUpdate
  221.      */
  222.     public function setUpdatedAt()
  223.     {
  224.         $this->updatedAt = new DateTime();
  225.         return $this;
  226.     }
  227.     /**
  228.      * @return bool
  229.      */
  230.     public function isLegacyLink()
  231.     {
  232.         return $this->legacyLink;
  233.     }
  234.     /**
  235.      * @param bool $legacyLink
  236.      */
  237.     public function setLegacyLink($legacyLink)
  238.     {
  239.         $this->legacyLink $legacyLink;
  240.     }
  241.     /**
  242.      * @return mixed
  243.      */
  244.     public function getSalePerson()
  245.     {
  246.         return $this->salePerson;
  247.     }
  248.     /**
  249.      * @param mixed $salePerson
  250.      */
  251.     public function setSalePerson($salePerson)
  252.     {
  253.         $this->salePerson $salePerson;
  254.     }
  255. }