src/Entity/Attachment.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Entity(repositoryClass\App\Repository\AttachmentRepository::class)]
  7. class Attachment implements \Stringable
  8. {
  9.     #[ORM\Id]
  10.     #[ORM\GeneratedValue]
  11.     #[ORM\Column(type'integer')]
  12.     private int $id;
  13.     #[ORM\Column(type'string'length255nullabletrue)]
  14.     private ?string $display_name"";
  15.     #[ORM\Column(type'string'length255nullabletrue)]
  16.     private ?string $size"";
  17.     #[ORM\Column(type'string'length255nullabletrue)]
  18.     private ?string $content_type"";
  19.     #[ORM\Column(type'string'length255nullabletrue)]
  20.     private ?string $url"";
  21.     #[ORM\ManyToMany(targetEntity\App\Entity\Post::class, mappedBy'attachments')]
  22.     private mixed $posts;
  23.     public function __construct()
  24.     {
  25.         $this->posts = new ArrayCollection();
  26.     }
  27.     public function getId(): ?int
  28.     {
  29.         return $this->id;
  30.     }
  31.     public function getDisplayName(): ?string
  32.     {
  33.         return $this->display_name;
  34.     }
  35.     public function setDisplayName(?string $display_name): self
  36.     {
  37.         $this->display_name $display_name;
  38.         return $this;
  39.     }
  40.     public function getSize(): ?string
  41.     {
  42.         return $this->size;
  43.     }
  44.     public function setSize(?string $size): self
  45.     {
  46.         $this->size $size;
  47.         return $this;
  48.     }
  49.     public function getContentType(): ?string
  50.     {
  51.         return $this->content_type;
  52.     }
  53.     public function setContentType(?string $content_type): self
  54.     {
  55.         $this->content_type $content_type;
  56.         return $this;
  57.     }
  58.     public function getUrl(): ?string
  59.     {
  60.         return $this->url;
  61.     }
  62.     public function setUrl(?string $url): self
  63.     {
  64.         $this->url $url;
  65.         return $this;
  66.     }
  67.     /**
  68.      * @return Collection|Post[]
  69.      */
  70.     public function getPosts(): Collection
  71.     {
  72.         return $this->posts;
  73.     }
  74.     public function addPost(Post $post): self
  75.     {
  76.         if (!$this->posts->contains($post)) {
  77.             $this->posts[] = $post;
  78.             $post->addAttachment($this);
  79.         }
  80.         return $this;
  81.     }
  82.     public function removePost(Post $post): self
  83.     {
  84.         if ($this->posts->contains($post)) {
  85.             $this->posts->removeElement($post);
  86.             $post->removeAttachment($this);
  87.         }
  88.         return $this;
  89.     }
  90.     public function __toString(): string
  91.     {
  92.         return (string) $this->display_name;
  93.     }
  94. }