src/Entity/GoodAssignement.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Validator\Constraints as AcmeAssert;
  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.  * GoodAssignement
  10.  *
  11.  * @AcmeAssert\GoodAssignement
  12.  */
  13. #[ORM\Entity(repositoryClass"App\Repository\GoodAssignementRepository")]
  14. #[ORM\Table(name"good_assignement")]
  15. #[UniqueEntity(fields: ["transferNumber"])]
  16. class GoodAssignement
  17. {
  18.     #[ORM\Column(type"boolean")]
  19.     private bool $isDeleted false;
  20.     #[ORM\Column(type"boolean")]
  21.     private bool $hasBuyerAccount false;
  22.     #[ORM\Column(name"createdAt"type"datetime")]
  23.     private DateTime $createdAt;
  24.     #[ORM\Column(type"datetime"nullabletrue)]
  25.     private ?DateTime $buyerValidationDate;
  26.     #[ORM\OneToOne(targetEntityItem::class, inversedBy"goodAssignement")]
  27.     private Item $newItem;
  28.     #[ORM\Column(name"id"type"integer")]
  29.     #[ORM\Id]
  30.     #[ORM\GeneratedValue(strategy"AUTO")]
  31.     private ?int $id;
  32.     #[ORM\ManyToOne(targetEntityUser::class, inversedBy"goodAssignements")]
  33.     #[ORM\JoinColumn(nullablefalse)]
  34.     private User $user;
  35.     #[AcmeAssert\ItemGoodAssignement]
  36.     #[ORM\ManyToOne(targetEntityItem::class, inversedBy"goodAssignements")]
  37.     #[ORM\JoinColumn(nullablefalse)]
  38.     private Item $item;
  39.     #[ORM\Column(name"transferNumber"type"string"length255nullabletrue)]
  40.     private ?string $transferNumber;
  41.     #[Assert\Choice(callback"getAssignementTypes"multiplefalse)]
  42.     #[ORM\Column(name"assignementType"type"string"length255nullabletrue)]
  43.     private ?string $assignementType null;
  44.     #[Assert\NotBlank(message'Ce champ est obligatoire'groups: ["noBuyerAccount"])]
  45.     #[ORM\Column(type"string"length255nullabletrue)]
  46.     private ?string $buyerPhoneNumber;
  47.     #[Assert\Choice(callback"getBuyerCivilitys"multiplefalse)]
  48.     #[Assert\NotBlank(message'Ce champ est obligatoire'groups: ["noBuyerAccount"])]
  49.     #[ORM\Column(type"string"length255nullabletrue)]
  50.     private ?string $buyerCivility;
  51.     /**
  52.      * @AcmeAssert\GoodAssignementBuyer
  53.      */
  54.     #[ORM\ManyToOne(targetEntityUser::class, inversedBy"buyerGoodAssignements")]
  55.     #[Assert\NotBlank(message'Ce champ est obligatoire'groups: ["hasBuyerAccount"])]
  56.     #[ORM\JoinColumn(nullabletrue)]
  57.     private ?User $buyer;
  58.     #[ORM\Column(name"saleAmount"type"decimal"precision10scale2nullabletrue)]
  59.     private ?float $saleAmount;
  60.     #[ORM\Column(name"transactionPlace"type"string"length255nullabletrue)]
  61.     private ?string $transactionPlace;
  62.     #[ORM\Column(name"transactionDate"type"datetimetz"nullabletrue)]
  63.     private ?DateTime $transactionDate;
  64.     #[Assert\NotBlank(message'Ce champ est obligatoire'groups: ["noBuyerAccount"])]
  65.     #[ORM\Column(name"buyerFirstName"type"string"length255nullabletrue)]
  66.     private ?string $buyerFirstName;
  67.     #[Assert\NotBlank(message'Ce champ est obligatoire'groups: ["noBuyerAccount"])]
  68.     #[ORM\Column(name"buyerLastName"type"string"length255nullabletrue)]
  69.     private ?string $buyerLastName;
  70.     #[ORM\Column(name"buyerAddress"type"string"length255nullabletrue)]
  71.     private ?string $buyerAddress;
  72.     #[Assert\NotBlank(message'Ce champ est obligatoire'groups: ["noBuyerAccount"])]
  73.     #[Assert\Email]
  74.     #[ORM\Column(name"buyerEmail"type"string"length255nullabletrue)]
  75.     private ?string $buyerEmail;
  76.     #[ORM\Column(name"paymentMeans"type"string"length255nullabletrue)]
  77.     private ?string $paymentMeans;
  78.     public function __construct()
  79.     {
  80.         $this->createdAt = new DateTime();
  81.         $this->transferNumber uniqid();
  82.     }
  83.     public function __toString()
  84.     {
  85.         return "#" $this->id " - " $this->transferNumber;
  86.     }
  87.     /**
  88.      *
  89.      */
  90.     public static function getPaymentsMeans()
  91.     {
  92.         $arr = [
  93.             'Espèces',
  94.             'Chèque',
  95.             'Chèque de banque',
  96.             'Virement bancaire'
  97.         ];
  98.         return array_combine($arr$arr);
  99.     }
  100.     /**
  101.      * Get id
  102.      *
  103.      * @return int
  104.      */
  105.     public function getId()
  106.     {
  107.         return $this->id;
  108.     }
  109.     public static function getAssignementTypes()
  110.     {
  111.         $arr = [
  112.             "Cession à titre gratuit" => "free",
  113.             "Cession à titre onéreux" => "sale"
  114.         ];
  115.         return $arr;
  116.     }
  117.     public static function getBuyerCivilitys()
  118.     {
  119.         $arr = [
  120.             "Monsieur" => "mr",
  121.             "Madame" => "mrs",
  122.         ];
  123.         return $arr;
  124.     }
  125.     /**
  126.      * Set transferNumber
  127.      *
  128.      * @param string $transferNumber
  129.      *
  130.      * @return GoodAssignement
  131.      */
  132.     public function setTransferNumber($transferNumber)
  133.     {
  134.         $this->transferNumber $transferNumber;
  135.         return $this;
  136.     }
  137.     /**
  138.      * Get transferNumber
  139.      *
  140.      * @return string
  141.      */
  142.     public function getTransferNumber()
  143.     {
  144.         return $this->transferNumber;
  145.     }
  146.     /**
  147.      * Set assignementType
  148.      *
  149.      * @param string $assignementType
  150.      *
  151.      * @return GoodAssignement
  152.      */
  153.     public function setAssignementType($assignementType)
  154.     {
  155.         $this->assignementType $assignementType;
  156.         return $this;
  157.     }
  158.     /**
  159.      * Get assignementType
  160.      *
  161.      * @return string
  162.      */
  163.     public function getAssignementType()
  164.     {
  165.         return $this->assignementType;
  166.     }
  167.     /**
  168.      * Set saleAmount
  169.      *
  170.      * @param string $saleAmount
  171.      *
  172.      * @return GoodAssignement
  173.      */
  174.     public function setSaleAmount($saleAmount)
  175.     {
  176.         $this->saleAmount $saleAmount;
  177.         return $this;
  178.     }
  179.     /**
  180.      * Get saleAmount
  181.      *
  182.      * @return string
  183.      */
  184.     public function getSaleAmount()
  185.     {
  186.         return $this->saleAmount;
  187.     }
  188.     /**
  189.      * Set transactionPlace
  190.      *
  191.      * @param string $transactionPlace
  192.      *
  193.      * @return GoodAssignement
  194.      */
  195.     public function setTransactionPlace($transactionPlace)
  196.     {
  197.         $this->transactionPlace $transactionPlace;
  198.         return $this;
  199.     }
  200.     /**
  201.      * Get transactionPlace
  202.      *
  203.      * @return string
  204.      */
  205.     public function getTransactionPlace()
  206.     {
  207.         return $this->transactionPlace;
  208.     }
  209.     /**
  210.      * Set transactionDate
  211.      *
  212.      * @param DateTime $transactionDate
  213.      *
  214.      * @return GoodAssignement
  215.      */
  216.     public function setTransactionDate($transactionDate)
  217.     {
  218.         $this->transactionDate $transactionDate;
  219.         return $this;
  220.     }
  221.     /**
  222.      * Get transactionDate
  223.      *
  224.      * @return DateTime
  225.      */
  226.     public function getTransactionDate()
  227.     {
  228.         return $this->transactionDate;
  229.     }
  230.     /**
  231.      * Set buyerFirstName
  232.      *
  233.      * @param string $buyerFirstName
  234.      *
  235.      * @return GoodAssignement
  236.      */
  237.     public function setBuyerFirstName($buyerFirstName)
  238.     {
  239.         $this->buyerFirstName $buyerFirstName;
  240.         return $this;
  241.     }
  242.     /**
  243.      * Get buyerFirstName
  244.      *
  245.      * @return string
  246.      */
  247.     public function getBuyerFirstName()
  248.     {
  249.         return $this->buyerFirstName;
  250.     }
  251.     /**
  252.      * Set buyerLastName
  253.      *
  254.      * @param string $buyerLastName
  255.      *
  256.      * @return GoodAssignement
  257.      */
  258.     public function setBuyerLastName($buyerLastName)
  259.     {
  260.         $this->buyerLastName $buyerLastName;
  261.         return $this;
  262.     }
  263.     /**
  264.      * Get buyerLastName
  265.      *
  266.      * @return string
  267.      */
  268.     public function getBuyerLastName()
  269.     {
  270.         return $this->buyerLastName;
  271.     }
  272.     /**
  273.      * Set buyerAddress
  274.      *
  275.      * @param string $buyerAddress
  276.      *
  277.      * @return GoodAssignement
  278.      */
  279.     public function setBuyerAddress($buyerAddress)
  280.     {
  281.         $this->buyerAddress $buyerAddress;
  282.         return $this;
  283.     }
  284.     /**
  285.      * Get buyerAddress
  286.      *
  287.      * @return string
  288.      */
  289.     public function getBuyerAddress()
  290.     {
  291.         return $this->buyerAddress;
  292.     }
  293.     /**
  294.      * Set buyerEmail
  295.      *
  296.      * @param string $buyerEmail
  297.      *
  298.      * @return GoodAssignement
  299.      */
  300.     public function setBuyerEmail($buyerEmail)
  301.     {
  302.         $this->buyerEmail $buyerEmail;
  303.         return $this;
  304.     }
  305.     /**
  306.      * Get buyerEmail
  307.      *
  308.      * @return string
  309.      */
  310.     public function getBuyerEmail()
  311.     {
  312.         return $this->buyerEmail;
  313.     }
  314.     /**
  315.      * Set paymentMeans
  316.      *
  317.      * @param string $paymentMeans
  318.      *
  319.      * @return GoodAssignement
  320.      */
  321.     public function setPaymentMeans($paymentMeans)
  322.     {
  323.         $this->paymentMeans $paymentMeans;
  324.         return $this;
  325.     }
  326.     /**
  327.      * Get paymentMeans
  328.      *
  329.      * @return string
  330.      */
  331.     public function getPaymentMeans()
  332.     {
  333.         return $this->paymentMeans;
  334.     }
  335.     /**
  336.      * Set createdAt
  337.      *
  338.      * @param DateTime $createdAt
  339.      *
  340.      * @return GoodAssignement
  341.      */
  342.     public function setCreatedAt($createdAt)
  343.     {
  344.         $this->createdAt $createdAt;
  345.         return $this;
  346.     }
  347.     /**
  348.      * Get createdAt
  349.      *
  350.      * @return DateTime
  351.      */
  352.     public function getCreatedAt()
  353.     {
  354.         return $this->createdAt;
  355.     }
  356.     /**
  357.      * Set user
  358.      *
  359.      * @param \App\Entity\User $user
  360.      *
  361.      * @return GoodAssignement
  362.      */
  363.     public function setUser(\App\Entity\User $user)
  364.     {
  365.         $this->user $user;
  366.         return $this;
  367.     }
  368.     /**
  369.      * Get user
  370.      *
  371.      * @return \App\Entity\User
  372.      */
  373.     public function getUser()
  374.     {
  375.         return $this->user;
  376.     }
  377.     /**
  378.      * Set item
  379.      *
  380.      * @param \App\Entity\Item $item
  381.      *
  382.      * @return GoodAssignement
  383.      */
  384.     public function setItem(\App\Entity\Item $item)
  385.     {
  386.         $this->item $item;
  387.         return $this;
  388.     }
  389.     /**
  390.      * Get item
  391.      *
  392.      * @return \App\Entity\Item
  393.      */
  394.     public function getItem()
  395.     {
  396.         return $this->item;
  397.     }
  398.     /**
  399.      * Set newItem
  400.      *
  401.      * @param \App\Entity\Item $newItem
  402.      *
  403.      * @return GoodAssignement
  404.      */
  405.     public function setNewItem(\App\Entity\Item $newItem null)
  406.     {
  407.         $this->newItem $newItem;
  408.         return $this;
  409.     }
  410.     /**
  411.      * Get newItem
  412.      *
  413.      * @return \App\Entity\Item
  414.      */
  415.     public function getNewItem()
  416.     {
  417.         return $this->newItem;
  418.     }
  419.     /**
  420.      * Set buyerValidationDate
  421.      *
  422.      * @param DateTime $buyerValidationDate
  423.      *
  424.      * @return GoodAssignement
  425.      */
  426.     public function setBuyerValidationDate($buyerValidationDate)
  427.     {
  428.         $this->buyerValidationDate $buyerValidationDate;
  429.         return $this;
  430.     }
  431.     /**
  432.      * Get buyerValidationDate
  433.      *
  434.      * @return DateTime
  435.      */
  436.     public function getBuyerValidationDate()
  437.     {
  438.         return $this->buyerValidationDate;
  439.     }
  440.     /**
  441.      * Set hasBuyerAccount
  442.      *
  443.      * @param boolean $hasBuyerAccount
  444.      *
  445.      * @return GoodAssignement
  446.      */
  447.     public function setHasBuyerAccount($hasBuyerAccount)
  448.     {
  449.         $this->hasBuyerAccount $hasBuyerAccount;
  450.         return $this;
  451.     }
  452.     /**
  453.      * Get hasBuyerAccount
  454.      *
  455.      * @return boolean
  456.      */
  457.     public function getHasBuyerAccount()
  458.     {
  459.         return $this->hasBuyerAccount;
  460.     }
  461.     /**
  462.      * Set buyerPhoneNumber
  463.      *
  464.      * @param string $buyerPhoneNumber
  465.      *
  466.      * @return GoodAssignement
  467.      */
  468.     public function setBuyerPhoneNumber($buyerPhoneNumber)
  469.     {
  470.         $this->buyerPhoneNumber $buyerPhoneNumber;
  471.         return $this;
  472.     }
  473.     /**
  474.      * Get buyerPhoneNumber
  475.      *
  476.      * @return string
  477.      */
  478.     public function getBuyerPhoneNumber()
  479.     {
  480.         return $this->buyerPhoneNumber;
  481.     }
  482.     /**
  483.      * Set buyerCivility
  484.      *
  485.      * @param string $buyerCivility
  486.      *
  487.      * @return GoodAssignement
  488.      */
  489.     public function setBuyerCivility($buyerCivility)
  490.     {
  491.         $this->buyerCivility $buyerCivility;
  492.         return $this;
  493.     }
  494.     /**
  495.      * Get buyerCivility
  496.      *
  497.      * @return string
  498.      */
  499.     public function getBuyerCivility()
  500.     {
  501.         return $this->buyerCivility;
  502.     }
  503.     /**
  504.      * Set buyer
  505.      *
  506.      * @param \App\Entity\User $buyer
  507.      *
  508.      * @return GoodAssignement
  509.      */
  510.     public function setBuyer(\App\Entity\User $buyer null)
  511.     {
  512.         $this->buyer $buyer;
  513.         return $this;
  514.     }
  515.     /**
  516.      * Get buyer
  517.      *
  518.      * @return \App\Entity\User
  519.      */
  520.     public function getBuyer()
  521.     {
  522.         return $this->buyer;
  523.     }
  524.     /**
  525.      * Set isDeleted
  526.      *
  527.      * @param boolean $isDeleted
  528.      *
  529.      * @return GoodAssignement
  530.      */
  531.     public function setIsDeleted($isDeleted)
  532.     {
  533.         $this->isDeleted $isDeleted;
  534.         return $this;
  535.     }
  536.     /**
  537.      * Get isDeleted
  538.      *
  539.      * @return boolean
  540.      */
  541.     public function getIsDeleted()
  542.     {
  543.         return $this->isDeleted;
  544.     }
  545. }