src/Entity/Document.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  5. /**
  6. * @ORM\Entity(repositoryClass="App\Repository\DocumentRepository")
  7. */
  8. class Document {
  9. /**
  10. * @ORM\Id()
  11. * @ORM\GeneratedValue()
  12. * @ORM\Column(type="integer")
  13. */
  14. private $id;
  15. /**
  16. * @ORM\Column(type="datetime")
  17. */
  18. private $created;
  19. /**
  20. * @ORM\Column(type="string", length=255)
  21. */
  22. private $type;
  23. /**
  24. * @ORM\Column(type="string", length=255)
  25. */
  26. private $name;
  27. /**
  28. * @ORM\ManyToOne(targetEntity="App\Entity\Customer", inversedBy="documents")
  29. * @ORM\JoinColumn(nullable=true)
  30. */
  31. private $customer;
  32. private $link;
  33. /**
  34. * @ORM\Column(type="datetime")
  35. */
  36. private $updated;
  37. private $linkFile;
  38. /**
  39. * Document constructor.
  40. * @throws \Exception
  41. */
  42. public function __construct() {
  43. $this->setCreated(new \DateTime());
  44. $this->setUpdated(new \DateTime());
  45. }
  46. /**
  47. * @return mixed
  48. */
  49. public function getLinkFile() {
  50. return $this->linkFile;
  51. }
  52. /**
  53. * @param $linkFile
  54. * @throws \Exception
  55. */
  56. public function setLinkFile($linkFile): void {
  57. $this->linkFile = $linkFile;
  58. // dump($linkFile->getExtension()); return;
  59. if (!empty($linkFile->getExtension())) {
  60. $this->setUpdated(new \DateTime());
  61. $this->setType($linkFile->getExtension());
  62. $this->setName($linkFile->getBasename());
  63. }
  64. }
  65. public function getId(): ?int {
  66. return $this->id;
  67. }
  68. public function getCreated(): ?\DateTimeInterface {
  69. return $this->created;
  70. }
  71. public function setCreated(\DateTimeInterface $created): self {
  72. $this->created = $created;
  73. return $this;
  74. }
  75. public function getType(): ?string {
  76. return $this->type;
  77. }
  78. public function setType(string $type): self {
  79. $this->type = $type;
  80. return $this;
  81. }
  82. public function getLink(): ?string {
  83. return $this->link;
  84. }
  85. public function setLink(?string $link): self {
  86. $this->link = $link;
  87. return $this;
  88. }
  89. public function getName(): ?string {
  90. return $this->name;
  91. }
  92. public function setName(string $name): self {
  93. $this->name = $name;
  94. return $this;
  95. }
  96. public function getCustomer(): ?Customer {
  97. return $this->customer;
  98. }
  99. public function setCustomer(?Customer $customer): self {
  100. $this->customer = $customer;
  101. return $this;
  102. }
  103. public function getUpdated(): ?\DateTimeInterface {
  104. return $this->updated;
  105. }
  106. public function setUpdated(\DateTimeInterface $updated): self {
  107. $this->updated = $updated;
  108. return $this;
  109. }
  110. }