src/Entity/Retrocession/Annonce.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Retrocession;
  3. use App\Entity\Adherent\Brand;
  4. use App\Entity\Adherent\Magasin;
  5. use App\Repository\Retrocession\AnnonceRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use Symfony\Component\Validator\Context\ExecutionContextInterface;
  11. use Symfony\Contracts\Translation\TranslatorInterface;
  12. #[ORM\Table(name'retrocession_annonce')]
  13. #[ORM\Entity(repositoryClassAnnonceRepository::class)]
  14. class Annonce implements \Stringable
  15. {
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column(type'integer')]
  19.     private $id;
  20.     #[ORM\ManyToOne(targetEntityMagasin::class, inversedBy'annonces')]
  21.     #[ORM\JoinColumn(name'magasin'referencedColumnName'k_adherent'nullablefalse)]
  22.     private $magasin;
  23.     #[ORM\Column(type'string'length255)]
  24.     private $refAnnonce;
  25.     #[ORM\Column(type'string'length255nullabletrue)]
  26.     private $refMonture;
  27.     #[ORM\Column(type'string'length255nullabletrue)]
  28.     private $supplier;
  29.     #[ORM\Column(type'string'length255nullabletrue)]
  30.     private $color;
  31.     #[ORM\Column(type'string'length255nullabletrue)]
  32.     private $calibre;
  33.     #[ORM\Column(type'string'length255nullabletrue)]
  34.     private $pont;
  35.     #[ORM\Column(type'integer'nullabletrue)]
  36.     private $quantity;
  37.     #[ORM\Column(type'datetime_immutable')]
  38.     private $created_at;
  39.     #[ORM\Column(type'datetime_immutable')]
  40.     private $disable_at;
  41.     #[ORM\Column(type'datetime_immutable')]
  42.     private $end_at;
  43.     #[ORM\OneToMany(mappedBy'annonce'targetEntityPhotos::class, cascade: ['persist''remove'])]
  44.     private $photos;
  45.     #[ORM\ManyToOne(targetEntityBrand::class, inversedBy'annonces')]
  46.     #[ORM\JoinColumn(nullabletrue)]
  47.     private $brand;
  48.     #[ORM\Column(type'string'length255nullabletrue)]
  49.     private $otherBrand;
  50.     #[ORM\Column(type"string"nullablefalse)]
  51.     private $region null;
  52.     #[ORM\Column(type"string"nullablefalse)]
  53.     private $pays "FR";
  54.     #[ORM\Column]
  55.     private ?bool $deleted null;
  56.     #[ORM\Column(length255nullabletrue)]
  57.     private ?string $type null;
  58.     #[ORM\Column(name'brouillon'type'boolean')]
  59.     private bool $brouillon false;
  60.     #[ORM\Column(name'reactivate'type'boolean')]
  61.     private bool $reactivate false;
  62.     public function __construct()
  63.     {
  64.         $this->created_at = new \DateTimeImmutable("now");
  65.         $interval_oneMonth = new \DateInterval('P1M');
  66.         $interval_twoMonth = new \DateInterval('P2M');
  67.         $this->disable_at $this->created_at->add($interval_oneMonth);
  68. //        $this->end_at = $this->created_at->add($interval_twoMonth);
  69.         $this->end_at $this->created_at->add($interval_oneMonth);
  70.         $this->deleted 0;
  71.         $this->photos = new ArrayCollection();
  72.         $this->refAnnonce 'A'.sprintf("%06d"random_int(1999999));
  73.     }
  74.     public function __toString(): string
  75.     {
  76.         return (string) $this->getRefAnnonce();
  77.     }
  78.     /**
  79.      * @return mixed
  80.      */
  81.     public function getId()
  82.     {
  83.         return $this->id;
  84.     }
  85.     public function setId(mixed $id): void
  86.     {
  87.         $this->id $id;
  88.     }
  89.     /**
  90.      * @return mixed
  91.      */
  92.     public function getMagasin()
  93.     {
  94.         return $this->magasin;
  95.     }
  96.     public function setMagasin(mixed $magasin): void
  97.     {
  98.         $this->magasin $magasin;
  99.     }
  100.     /**
  101.      * @return mixed
  102.      */
  103.     public function getRefAnnonce()
  104.     {
  105.         return $this->refAnnonce;
  106.     }
  107.     public function setRefAnnonce(mixed $refAnnonce): void
  108.     {
  109.         $this->refAnnonce $refAnnonce;
  110.     }
  111.     /**
  112.      * @return mixed
  113.      */
  114.     public function getRefMonture()
  115.     {
  116.         return $this->refMonture;
  117.     }
  118.     public function setRefMonture(mixed $refMonture): void
  119.     {
  120.         $this->refMonture $refMonture;
  121.     }
  122.     /**
  123.      * @return mixed
  124.      */
  125.     public function getSupplier()
  126.     {
  127.         return $this->supplier;
  128.     }
  129.     public function setSupplier(mixed $supplier): void
  130.     {
  131.         $this->supplier $supplier;
  132.     }
  133.     /**
  134.      * @return mixed
  135.      */
  136.     public function getColor()
  137.     {
  138.         return $this->color;
  139.     }
  140.     public function setColor(mixed $color): void
  141.     {
  142.         $this->color $color;
  143.     }
  144.     /**
  145.      * @return mixed
  146.      */
  147.     public function getCalibre()
  148.     {
  149.         return $this->calibre;
  150.     }
  151.     public function setCalibre(mixed $calibre): void
  152.     {
  153.         $this->calibre $calibre;
  154.     }
  155.     /**
  156.      * @return mixed
  157.      */
  158.     public function getPont()
  159.     {
  160.         return $this->pont;
  161.     }
  162.     public function setPont(mixed $pont): void
  163.     {
  164.         $this->pont $pont;
  165.     }
  166.     /**
  167.      * @return mixed
  168.      */
  169.     public function getQuantity()
  170.     {
  171.         return $this->quantity;
  172.     }
  173.     public function setQuantity(mixed $quantity): void
  174.     {
  175.         $this->quantity $quantity;
  176.     }
  177.     public function getCreatedAt(): \DateTimeImmutable
  178.     {
  179.         return $this->created_at;
  180.     }
  181.     public function setCreatedAt(\DateTimeImmutable $created_at): void
  182.     {
  183.         $this->created_at $created_at;
  184.     }
  185.     public function getDisableAt(): \DateTimeImmutable
  186.     {
  187.         return $this->disable_at;
  188.     }
  189.     public function setDisableAt(\DateTimeImmutable $disable_at): void
  190.     {
  191.         $this->disable_at $disable_at;
  192.     }
  193.     public function getEndAt(): \DateTimeImmutable
  194.     {
  195.         return $this->end_at;
  196.     }
  197.     public function setEndAt(\DateTimeImmutable $end_at): void
  198.     {
  199.         $this->end_at $end_at;
  200.     }
  201.     /**
  202.      * @return Collection<int, Photos>
  203.      */
  204.     public function getPhotos(): Collection
  205.     {
  206.         return $this->photos;
  207.     }
  208.     public function addPhoto(Photos $photo): self
  209.     {
  210.         if (!$this->photos->contains($photo)) {
  211.             $this->photos[] = $photo;
  212.             $photo->setAnnonce($this);
  213.         }
  214.         return $this;
  215.     }
  216.     public function removePhoto(Photos $photo): self
  217.     {
  218.         if ($this->photos->removeElement($photo)) {
  219.             // set the owning side to null (unless already changed)
  220.             if ($photo->getAnnonce() === $this) {
  221.                 $photo->setAnnonce(null);
  222.             }
  223.         }
  224.         return $this;
  225.     }
  226.     public function getBrand(): ?Brand
  227.     {
  228.         return $this->brand;
  229.     }
  230.     public function setBrand(?Brand $brand): self
  231.     {
  232.         $this->brand $brand;
  233.         return $this;
  234.     }
  235.     public function getRegion()
  236.     {
  237.         return $this->region;
  238.     }
  239.     public function setRegion($region): self
  240.     {
  241.         $this->region $region;
  242.         return $this;
  243.     }
  244.     /**
  245.      * @return string
  246.      */
  247.     public function getPays(): string
  248.     {
  249.         return $this->pays;
  250.     }
  251.     /**
  252.      * @param string $pays
  253.      */
  254.     public function setPays(string $pays): void
  255.     {
  256.         $this->pays $pays;
  257.     }
  258.     public function isDeleted(): ?bool
  259.     {
  260.         return $this->deleted;
  261.     }
  262.     public function setDeleted(bool $deleted): self
  263.     {
  264.         $this->deleted $deleted;
  265.         return $this;
  266.     }
  267.     public function getType(): ?string
  268.     {
  269.         return $this->type;
  270.     }
  271.     public function setType(string $type): self
  272.     {
  273.         $this->type $type;
  274.         return $this;
  275.     }
  276.     /**
  277.      * @return mixed
  278.      */
  279.     public function getOtherBrand()
  280.     {
  281.         return $this->otherBrand;
  282.     }
  283.     /**
  284.      * @param mixed $otherBrand
  285.      */
  286.     public function setOtherBrand($otherBrand): void
  287.     {
  288.         $this->otherBrand $otherBrand;
  289.     }
  290. //    #[Assert\Callback]
  291. //    public function validate(ExecutionContextInterface $context, $payload)
  292. //    {
  293. //
  294. //        dd($this);
  295. //        if (null === $this->getBrand() && null === $this->getOtherBrand()){
  296. //            $context->buildViolation('veuillez.renseigner.une.marque')
  297. //                ->atPath('brand')
  298. //                ->addViolation();
  299. //        }
  300. //    }
  301.     public function isBrouillon(): ?bool
  302.     {
  303.         return $this->brouillon;
  304.     }
  305.     public function setBrouillon(bool $brouillon): self
  306.     {
  307.         $this->brouillon $brouillon;
  308.         return $this;
  309.     }
  310.     public function isReactivate(): ?bool
  311.     {
  312.         return $this->reactivate;
  313.     }
  314.     public function setReactivate(bool $reactivate): self
  315.     {
  316.         $this->reactivate $reactivate;
  317.         return $this;
  318.     }
  319. }