src/Entity/Photo.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  4. use Symfony\Component\HttpFoundation\File\File;
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Table(name: 'photos')]
  7. #[ORM\Entity]
  8. #[Vich\Uploadable]
  9. class Photo
  10. {
  11. #[ORM\Column(name: 'id', type: 'integer', nullable: false)]
  12. #[ORM\Id]
  13. #[ORM\GeneratedValue(strategy: 'IDENTITY')]
  14. private $id;
  15. #[Vich\UploadableField(mapping: 'photos', fileNameProperty: 'image')]
  16. private $imageFile;
  17. #[ORM\Column(type: 'string', length: 250, nullable: true)]
  18. private $image;
  19. #[ORM\Column(name: 'created', type: 'datetime', nullable: true)]
  20. private $created;
  21. #[ORM\ManyToOne(targetEntity: Projects::class, inversedBy: 'photos')]
  22. private $project;
  23. #[ORM\ManyToOne(targetEntity: User::class)]
  24. private $user;
  25. public function getId(): ?int
  26. {
  27. return $this->id;
  28. }
  29. public function getCreated(): ?\DateTimeInterface
  30. {
  31. return $this->created;
  32. }
  33. public function setCreated(\DateTimeInterface $created): self
  34. {
  35. $this->created = $created;
  36. return $this;
  37. }
  38. /**
  39. * @return mixed
  40. */
  41. public function getImageFile()
  42. {
  43. return $this->imageFile;
  44. }
  45. /**
  46. * @param mixed $imageFile
  47. */
  48. public function setImageFile(File $imageFile)
  49. {
  50. $this->imageFile = $imageFile;
  51. return $this;
  52. }
  53. public function getPreview(): ?string
  54. {
  55. return $this->getProject()->getCustomer()->getId()."/".$this->image;
  56. }
  57. public function getImage(): ?string
  58. {
  59. return $this->image;
  60. }
  61. public function setImage(?string $image): self
  62. {
  63. $this->image = $image;
  64. return $this;
  65. }
  66. public function __toString()
  67. {
  68. return (string)$this->image;
  69. }
  70. public function getProject(): ?Projects
  71. {
  72. return $this->project;
  73. }
  74. public function setProject(?Projects $project): self
  75. {
  76. $this->project = $project;
  77. return $this;
  78. }
  79. public function getUser(): ?User
  80. {
  81. return $this->user;
  82. }
  83. public function setUser(?User $user): self
  84. {
  85. $this->user = $user;
  86. return $this;
  87. }
  88. }