<?php
namespace App\Entity;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\OffersRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Doctrine\ORM\Mapping\JoinTable;
use Doctrine\ORM\Mapping\JoinColumn;
/**
* @ApiResource()
* @ORM\Entity(repositoryClass=OffersRepository::class)
* @Vich\Uploadable
*/
class Offers
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
*@ORM\Column(type="string", length=255)
* @ORM\JoinColumn(nullable=true)
*/
private $status;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="offers")
* @ORM\JoinColumn(nullable=false)
*/
private $user;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\AccountForm", mappedBy="offers")
* @JoinTable(name="offers_account_form",
* joinColumns={@JoinColumn(name="offers_id", referencedColumnName="id")},
* inverseJoinColumns={@JoinColumn(name="account_form_id", referencedColumnName="id")}
* )
*/
private $accountForm;
/**
* @ORM\Column(type="string", length=255)
* @ORM\JoinColumn(nullable=true)
*/
private $title;
/**
* @ORM\Column(type="text")
*/
private $content;
/**
* @ORM\Column(type="string")
*/
private $createdAt;
/**
* @ORM\Column(type="string", length=255)
*/
private $address;
/**
* @ORM\Column(type="string", length=255)
*/
private $codePostal;
/**
* @ORM\Column(type="string", length=255)
*/
private $city;
/**
* @ORM\Column(type="string", length=255)
*/
private $latitude;
/**
* @ORM\Column(type="string", length=255)
*/
private $longitude;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $category;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Proposal", mappedBy="offer")
*/
private $proposals;
/**
* @ORM\Column(type="string", length=255,nullable=true)
*/
private $distance;
/**
* @ORM\Column(type="string", length=255,nullable=true)
*/
private $duration;
/**
* @ORM\OneToMany(targetEntity=ImageProposal::class, mappedBy="offers",cascade={"persist"})
*/
private $images;
public function __construct()
{
$this->accountForm = new ArrayCollection();
$this->createdAt = date('d-m-Y h:i:s');
$this->status = 'PubliƩe';
$this->proposals = new ArrayCollection();
$this->images = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title="title"): self
{
$this->title = $title;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(string $content): self
{
$this->content = $content;
return $this;
}
public function getCreatedAt()
{
return $this->createdAt;
}
public function setCreatedAt( $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(string $address): self
{
$this->address = $address;
return $this;
}
public function getCodePostal(): ?string
{
return $this->codePostal;
}
public function setCodePostal(string $codePostal): self
{
$this->codePostal = $codePostal;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(string $city): self
{
$this->city = $city;
return $this;
}
public function getLatitude(): ?string
{
return $this->latitude;
}
public function setLatitude(string $latitude): self
{
$this->latitude = $latitude;
return $this;
}
public function getLongitude(): ?string
{
return $this->longitude;
}
public function setLongitude(string $longitude): self
{
$this->longitude = $longitude;
return $this;
}
public function getCategory(): ?string
{
return $this->category;
}
public function setCategory(?string $category): self
{
$this->category = $category;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(?string $status): self
{
$this->status = $status;
return $this;
}
public function getDuration(): ?string
{
return $this->duration;
}
public function setDuration(?string $duration): self
{
$this->duration = $duration;
return $this;
}
public function getDistance(): ?string
{
return $this->distance;
}
public function setDistance(?string $distance): self
{
$this->distance = $distance;
return $this;
}
/**
* @return Collection|AccountForm[]
*/
public function getAccountForm(): Collection{
return $this->accountForm;
}
public function addAccountForm(AccountForm $accountForm): self
{
if (!$this->accountForm->contains($accountForm)) {
$this->accountForm->add($accountForm);
$accountForm->addOffer($this);
}
return $this;
}
public function removeAccountForm(AccountForm $accountForm)
{
if( $this->accountForm->removeElement($accountForm))
$accountForm->removeOffer($this);
return $this;
}
/**
* @return Collection|Proposal[]
*/
public function getProposals(): Collection
{
return $this->proposals;
}
public function addProposal(Proposal $proposal): self
{
if (!$this->proposals->contains($proposal)) {
$this->proposals[] = $proposal;
$proposal->setOffer($this);
}
return $this;
}
public function removeProposal(Proposal $proposal): self
{
if ($this->proposals->removeElement($proposal)) {
// set the owning side to null (unless already changed)
if ($proposal->getOffer() === $this) {
$proposal->setOffer(null);
}
}
return $this;
}
/**
* @return Collection|ImageProposal[]
*/
public function getImages(): Collection
{
return $this->images;
}
public function addImage(?ImageProposal $image): self
{
if (!$this->images->contains($image)) {
$this->images[] = $image;
$image->setOffers($this);
}
return $this;
}
public function removeImage(ImageProposal $image): self
{
if ($this->images->removeElement($image)) {
// set the owning side to null (unless already changed)
if ($image->getOffers() === $this) {
$image->setOffers(null);
}
}
return $this;
}
}