src/Entity/Company.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CompanyRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\HttpFoundation\File\File;
  8. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  9. /**
  10.  * @Vich\Uploadable
  11.  * @ORM\Entity(repositoryClass=CompanyRepository::class)
  12.  * @ORM\Table
  13.  */
  14. class Company
  15. {
  16.     /**
  17.      * @ORM\Id()
  18.      * @ORM\GeneratedValue()
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="string", length=255)
  24.      */
  25.     private $name;
  26.     /**
  27.      * @ORM\Column(type="text", nullable=true)
  28.      */
  29.     private $url;
  30.     /**
  31.      * @ORM\Column(type="text")
  32.      */
  33.     private $description;
  34.     /**
  35.      * @ORM\OneToOne(targetEntity=User::class, inversedBy="company", cascade={"persist", "remove"})
  36.      */
  37.     private $user;
  38.     /**
  39.      * @ORM\OneToMany(targetEntity=Job::class, mappedBy="company")
  40.      */
  41.     private $jobs;
  42.     /**
  43.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  44.      *
  45.      * @var File
  46.      *
  47.      * @Vich\UploadableField(mapping="company_image", fileNameProperty="archivo", originalName="file_original_name")
  48.      */
  49.     protected $archivoFile;
  50.     /**
  51.      * @var string
  52.      *
  53.      * @ORM\Column(type="string", length=255, name="file_original_name", nullable = true)
  54.      */
  55.     protected $file_original_name;
  56.     /**
  57.      * @var string
  58.      *
  59.      * @ORM\Column(type="string", length=255, nullable=true)
  60.      */
  61.     private $archivo;
  62.     /**
  63.      * @var \DateTime
  64.      *
  65.      * @ORM\Column(type="datetime", nullable=true)
  66.      */
  67.     private $updateAt;
  68.     public function __construct()
  69.     {
  70.         $this->jobs = new ArrayCollection();
  71.     }
  72.     public function getId(): ?int
  73.     {
  74.         return $this->id;
  75.     }
  76.     public function getName(): ?string
  77.     {
  78.         return $this->name;
  79.     }
  80.     public function setName(string $name): self
  81.     {
  82.         $this->name $name;
  83.         return $this;
  84.     }
  85.     public function getUrl(): ?string
  86.     {
  87.         return $this->url;
  88.     }
  89.     public function setUrl(string $url): self
  90.     {
  91.         $this->url $url;
  92.         return $this;
  93.     }
  94.     public function getDescription(): ?string
  95.     {
  96.         return $this->description;
  97.     }
  98.     public function setDescription(string $description): self
  99.     {
  100.         $this->description $description;
  101.         return $this;
  102.     }
  103.     public function getUser(): ?User
  104.     {
  105.         return $this->user;
  106.     }
  107.     public function setUser(?User $user): self
  108.     {
  109.         $this->user $user;
  110.         return $this;
  111.     }
  112.     /**
  113.      * @return Collection|Job[]
  114.      */
  115.     public function getJobs(): Collection
  116.     {
  117.         return $this->jobs;
  118.     }
  119.     public function addJob(Job $job): self
  120.     {
  121.         if (!$this->jobs->contains($job)) {
  122.             $this->jobs[] = $job;
  123.             $job->setCompany($this);
  124.         }
  125.         return $this;
  126.     }
  127.     public function removeJob(Job $job): self
  128.     {
  129.         if ($this->jobs->contains($job)) {
  130.             $this->jobs->removeElement($job);
  131.             // set the owning side to null (unless already changed)
  132.             if ($job->getCompany() === $this) {
  133.                 $job->setCompany(null);
  134.             }
  135.         }
  136.         return $this;
  137.     }
  138.     /**
  139.      * @return string
  140.      */
  141.     public function getArchivo(): ?string
  142.     {
  143.         return $this->archivo;
  144.     }
  145.     /**
  146.      * @param string $archivo
  147.      */
  148.     public function setArchivo($archivo)
  149.     {
  150.         $this->archivo $archivo;
  151.     }
  152.     /**
  153.      * @return File
  154.      */
  155.     public function getArchivoFile(): ?File
  156.     {
  157.         return $this->archivoFile;
  158.     }
  159.     /**
  160.      * @return string
  161.      */
  162.     public function getFileOriginalName(): ?string
  163.     {
  164.         return $this->file_original_name;
  165.     }
  166.     /**
  167.      * @param string $file_original_name
  168.      */
  169.     public function setFileOriginalName($file_original_name)
  170.     {
  171.         $this->file_original_name $file_original_name;
  172.     }
  173.     /**
  174.      * @return \DateTime
  175.      */
  176.     public function getUpdateAt(): \DateTime
  177.     {
  178.         return $this->updateAt;
  179.     }
  180.     /**
  181.      * @param \DateTime $updateAt
  182.      */
  183.     public function setUpdateAt($updateAt)
  184.     {
  185.         $this->updateAt $updateAt;
  186.     }
  187.     /**
  188.      * @param File|null $archivoFile
  189.      *
  190.      * @throws \Exception
  191.      */
  192.     public function setArchivoFile(File $archivoFile null)
  193.     {
  194.         $this->archivoFile $archivoFile;
  195.         $this->updateAt = new \DateTime('now');
  196.     }
  197.     public function __toString()
  198.     {
  199.         return $this->getName();
  200.     }
  201. }