src/Entity/Offers.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use App\Repository\OffersRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\HttpFoundation\File\File;
  10. use Doctrine\ORM\Mapping\JoinTable;
  11. use Doctrine\ORM\Mapping\JoinColumn;
  12. /**
  13.  * @ApiResource()
  14.  * @ORM\Entity(repositoryClass=OffersRepository::class)
  15.  * @Vich\Uploadable
  16.  */
  17. class Offers
  18. {
  19.     /**
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue
  22.      * @ORM\Column(type="integer")
  23.      */
  24.     private $id;
  25.     /**
  26.      *@ORM\Column(type="string", length=255)
  27.      * @ORM\JoinColumn(nullable=true)
  28.      */
  29.     private $status;
  30.     /**
  31.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="offers")
  32.      * @ORM\JoinColumn(nullable=false)
  33.      */
  34.     private $user;
  35.      /**
  36.      * @ORM\ManyToMany(targetEntity="App\Entity\AccountForm", mappedBy="offers")
  37.      * @JoinTable(name="offers_account_form",
  38.      *      joinColumns={@JoinColumn(name="offers_id", referencedColumnName="id")},
  39.      *     inverseJoinColumns={@JoinColumn(name="account_form_id", referencedColumnName="id")}
  40.      * )
  41.      */ 
  42.     private $accountForm;
  43.     /**
  44.      * @ORM\Column(type="string", length=255)
  45.      * @ORM\JoinColumn(nullable=true)
  46.      */
  47.     private $title;
  48.     /**
  49.      * @ORM\Column(type="text")
  50.      */
  51.     private $content;
  52.     /**
  53.      * @ORM\Column(type="string")
  54.      */
  55.     private $createdAt;
  56.     /**
  57.      * @ORM\Column(type="string", length=255)
  58.      */
  59.     private $address;
  60.     /**
  61.      * @ORM\Column(type="string", length=255)
  62.      */
  63.     private $codePostal;
  64.     /**
  65.      * @ORM\Column(type="string", length=255)
  66.      */
  67.     private $city;
  68.     /**
  69.      * @ORM\Column(type="string", length=255)
  70.      */
  71.     private $latitude;
  72.     /**
  73.      * @ORM\Column(type="string", length=255)
  74.      */
  75.     private $longitude;
  76.     /**
  77.      * @ORM\Column(type="string", length=255, nullable=true)
  78.      */
  79.     private $category;
  80.     /**
  81.      * @ORM\OneToMany(targetEntity="App\Entity\Proposal", mappedBy="offer")
  82.      */
  83.     private $proposals;
  84.     /**
  85.      * @ORM\Column(type="string", length=255,nullable=true)
  86.      */
  87.     private $distance;
  88.     
  89.     /**
  90.     * @ORM\Column(type="string", length=255,nullable=true)
  91.     */
  92.    private $duration;
  93.    /**
  94.     * @ORM\OneToMany(targetEntity=ImageProposal::class, mappedBy="offers",cascade={"persist"})
  95.     */
  96.    private $images;
  97.     public function __construct()
  98.     {
  99.         $this->accountForm = new ArrayCollection();
  100.         $this->createdAt date('d-m-Y h:i:s');
  101.         $this->status 'PubliĆ©e';
  102.         $this->proposals = new ArrayCollection();
  103.         $this->images = new ArrayCollection();
  104.     }
  105.     public function getId(): ?int
  106.     {
  107.         return $this->id;
  108.     }
  109.     public function getUser(): ?User
  110.     {
  111.         return $this->user;
  112.     }
  113.     public function setUser(?User $user): self
  114.     {
  115.         $this->user $user;
  116.         return $this;
  117.     }
  118.     public function getTitle(): ?string
  119.     {
  120.         return $this->title;
  121.     }
  122.     public function setTitle(string $title="title"): self
  123.     {
  124.         $this->title $title;
  125.         return $this;
  126.     }
  127.      
  128.     public function getContent(): ?string
  129.     {
  130.         return $this->content;
  131.     }
  132.     public function setContent(string $content): self
  133.     {
  134.         $this->content $content;
  135.         return $this;
  136.     }
  137.     public function getCreatedAt()
  138.     {
  139.         return $this->createdAt;
  140.     }
  141.     public function setCreatedAt$createdAt): self
  142.     {
  143.         $this->createdAt $createdAt;
  144.         return $this;
  145.     }
  146.     public function getAddress(): ?string
  147.     {
  148.         return $this->address;
  149.     }
  150.     public function setAddress(string $address): self
  151.     {
  152.         $this->address $address;
  153.         return $this;
  154.     }
  155.     public function getCodePostal(): ?string
  156.     {
  157.         return $this->codePostal;
  158.     }
  159.     public function setCodePostal(string $codePostal): self
  160.     {
  161.         $this->codePostal $codePostal;
  162.         return $this;
  163.     }
  164.     public function getCity(): ?string
  165.     {
  166.         return $this->city;
  167.     }
  168.     public function setCity(string $city): self
  169.     {
  170.         $this->city $city;
  171.         return $this;
  172.     }
  173.     public function getLatitude(): ?string
  174.     {
  175.         return $this->latitude;
  176.     }
  177.     public function setLatitude(string $latitude): self
  178.     {
  179.         $this->latitude $latitude;
  180.         return $this;
  181.     }
  182.     public function getLongitude(): ?string
  183.     {
  184.         return $this->longitude;
  185.     }
  186.     public function setLongitude(string $longitude): self
  187.     {
  188.         $this->longitude $longitude;
  189.         return $this;
  190.     }
  191.     public function getCategory(): ?string
  192.     {
  193.         return $this->category;
  194.     }
  195.     public function setCategory(?string $category): self
  196.     {
  197.         $this->category $category;
  198.         return $this;
  199.     }
  200.     public function getStatus(): ?string
  201.     {
  202.         return $this->status;
  203.     }
  204.     public function setStatus(?string $status): self
  205.     {
  206.         $this->status $status;
  207.         return $this;
  208.     }
  209.     public function getDuration(): ?string
  210.     {
  211.         return $this->duration;
  212.     }
  213.     public function setDuration(?string $duration): self
  214.     {
  215.         $this->duration $duration;
  216.         return $this;
  217.     }
  218.     public function getDistance(): ?string
  219.     {
  220.         return $this->distance;
  221.     }
  222.     public function setDistance(?string $distance): self
  223.     {
  224.         $this->distance $distance;
  225.         return $this;
  226.     }
  227.     /**
  228.      * @return Collection|AccountForm[]
  229.      */
  230.     public function getAccountForm(): Collection{
  231.         return $this->accountForm;
  232.     }
  233.     public function addAccountForm(AccountForm $accountForm): self
  234.     {
  235.         if (!$this->accountForm->contains($accountForm)) {
  236.             $this->accountForm->add($accountForm);
  237.             $accountForm->addOffer($this);
  238.         }
  239.         return $this;
  240.     }
  241.     public function removeAccountForm(AccountForm $accountForm)
  242.     {
  243.         if( $this->accountForm->removeElement($accountForm))
  244.         $accountForm->removeOffer($this);
  245.         return $this;
  246.     }
  247.     /**
  248.      * @return Collection|Proposal[]
  249.      */
  250.     public function getProposals(): Collection
  251.     {
  252.         return $this->proposals;
  253.     }
  254.     public function addProposal(Proposal $proposal): self
  255.     {
  256.         if (!$this->proposals->contains($proposal)) {
  257.             $this->proposals[] = $proposal;
  258.             $proposal->setOffer($this);
  259.         }
  260.         return $this;
  261.     }
  262.     public function removeProposal(Proposal $proposal): self
  263.     {
  264.         if ($this->proposals->removeElement($proposal)) {
  265.             // set the owning side to null (unless already changed)
  266.             if ($proposal->getOffer() === $this) {
  267.                 $proposal->setOffer(null);
  268.             }
  269.         }
  270.         return $this;
  271.     }
  272.     /**
  273.      * @return Collection|ImageProposal[]
  274.      */
  275.     public function getImages(): Collection
  276.     {
  277.         return $this->images;
  278.     }
  279.     public function addImage(?ImageProposal $image): self
  280.     {
  281.         if (!$this->images->contains($image)) {
  282.             $this->images[] = $image;
  283.             $image->setOffers($this);
  284.         }
  285.         return $this;
  286.     }
  287.     public function removeImage(ImageProposal $image): self
  288.     {
  289.         if ($this->images->removeElement($image)) {
  290.             // set the owning side to null (unless already changed)
  291.             if ($image->getOffers() === $this) {
  292.                 $image->setOffers(null);
  293.             }
  294.         }
  295.         return $this;
  296.     }
  297. }