src/Entity/Projet/Portfolio/Imgportfolio.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Projet\Portfolio;
  3. use App\Entity\Users\User\User;
  4. use App\Repository\Projet\Portfolio\ImgportfolioRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\HttpFoundation\File\File;
  7. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  8. /**
  9.  * @ORM\Table(name="`imgportfolio`")
  10.  * @ORM\Entity(repositoryClass=ImgportfolioRepository::class)
  11.  * @ORM\HasLifecycleCallbacks
  12.  * @Vich\Uploadable
  13.  */
  14. class Imgportfolio
  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 $title;
  26.     /**
  27.      * @ORM\Column(type="datetime")
  28.      */
  29.     private $createdAt;
  30.     /**
  31.      * @ORM\ManyToOne(targetEntity=Intervention::class)
  32.      * @ORM\JoinColumn(nullable=false)
  33.      */
  34.     private $intervention;
  35.     /**
  36.      * @ORM\Column(type="integer")
  37.      */
  38.     private $rang;
  39.     /**
  40.      * @ORM\Column(type="string", length=255, nullable=true)
  41.      */
  42.     public $contentUrl;
  43.     /**
  44.      * @ORM\Column(type="string", length=255, nullable=true)
  45.      */
  46.     private $filePath;
  47.     /**
  48.      * @Vich\UploadableField(mapping="file_imgportfolio", fileNameProperty="filePath", size="imageSize", mimeType="mimeType", originalName="originalName")
  49.      * @var File|null
  50.      */
  51.     public ?File $file null;
  52.     /**
  53.      * @ORM\Column(type="string", length=255, nullable=true)
  54.      */
  55.     private $imageSize;
  56.     /**
  57.      * @ORM\Column(type="string", length=255, nullable=true)
  58.      */
  59.     private $originalName;
  60.     /**
  61.      * @ORM\Column(type="string", length=255, nullable=true)
  62.      */
  63.     private $mimeType;
  64.     /**
  65.      * @ORM\ManyToOne(targetEntity=User::class)
  66.      */
  67.     private $user;
  68.     public function __construct()
  69.     {
  70.         $this->createdAt = new \Datetime();
  71.         $this->rang 0;
  72.     }
  73.     public function getId(): ?int
  74.     {
  75.         return $this->id;
  76.     }
  77.     public function getTitle(): ?string
  78.     {
  79.         return $this->title;
  80.     }
  81.     public function setTitle(string $title): self
  82.     {
  83.         $this->title $title;
  84.         return $this;
  85.     }
  86.     public function getCreatedAt(): ?\DateTimeInterface
  87.     {
  88.         return $this->createdAt;
  89.     }
  90.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  91.     {
  92.         $this->createdAt $createdAt;
  93.         return $this;
  94.     }
  95.     public function getIntervention(): ?Intervention
  96.     {
  97.         return $this->intervention;
  98.     }
  99.     public function setIntervention(?Intervention $intervention): self
  100.     {
  101.         $this->intervention $intervention;
  102.         return $this;
  103.     }
  104.     /**
  105.     * @ORM\PrePersist()
  106.     */
  107.     public function preUpload()
  108.     {
  109.         $this->intervention->setImgNumber($this->intervention->getImgNumber() + 1);
  110.     }
  111.     /**
  112.     * @ORM\PostRemove()
  113.     */
  114.     public function postDelete()
  115.     {
  116.         $this->intervention->setImgNumber($this->intervention->getImgNumber() - 1);
  117.     }
  118.     public function getRang(): ?int
  119.     {
  120.         return $this->rang;
  121.     }
  122.     public function setRang(int $rang): self
  123.     {
  124.         $this->rang $rang;
  125.         return $this;
  126.     }
  127.     public function getUser(): ?User
  128.     {
  129.         return $this->user;
  130.     }
  131.     public function setUser(?User $user): self
  132.     {
  133.         $this->user $user;
  134.         return $this;
  135.     }
  136.     public function getContentUrl(): ?string
  137.     {
  138.         return $this->contentUrl;
  139.     }
  140.     public function setContentUrl(?string $contentUrl): self
  141.     {
  142.         $this->contentUrl $contentUrl;
  143.         return $this;
  144.     }
  145.     public function getFilePath(): ?string
  146.     {
  147.         return $this->filePath;
  148.     }
  149.     public function setFilePath(?string $filePath): self
  150.     {
  151.         $this->filePath $filePath;
  152.         return $this;
  153.     }
  154.     public function getImageSize(): ?string
  155.     {
  156.         return $this->imageSize;
  157.     }
  158.     public function setImageSize(?string $imageSize): self
  159.     {
  160.         $this->imageSize $imageSize;
  161.         return $this;
  162.     }
  163.     public function getOriginalName(): ?string
  164.     {
  165.         return $this->originalName;
  166.     }
  167.     public function setOriginalName(?string $originalName): self
  168.     {
  169.         $this->originalName $originalName;
  170.         return $this;
  171.     }
  172.     public function getMimeType(): ?string
  173.     {
  174.         return $this->mimeType;
  175.     }
  176.     public function setMimeType(string $mimeType null): self
  177.     {
  178.         $this->mimeType $mimeType;
  179.         return $this;
  180.     }
  181. }