<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: \App\Repository\AttachmentRepository::class)]
class Attachment implements \Stringable
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private int $id;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $display_name= "";
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $size= "";
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $content_type= "";
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $url= "";
#[ORM\ManyToMany(targetEntity: \App\Entity\Post::class, mappedBy: 'attachments')]
private mixed $posts;
public function __construct()
{
$this->posts = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getDisplayName(): ?string
{
return $this->display_name;
}
public function setDisplayName(?string $display_name): self
{
$this->display_name = $display_name;
return $this;
}
public function getSize(): ?string
{
return $this->size;
}
public function setSize(?string $size): self
{
$this->size = $size;
return $this;
}
public function getContentType(): ?string
{
return $this->content_type;
}
public function setContentType(?string $content_type): self
{
$this->content_type = $content_type;
return $this;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setUrl(?string $url): self
{
$this->url = $url;
return $this;
}
/**
* @return Collection|Post[]
*/
public function getPosts(): Collection
{
return $this->posts;
}
public function addPost(Post $post): self
{
if (!$this->posts->contains($post)) {
$this->posts[] = $post;
$post->addAttachment($this);
}
return $this;
}
public function removePost(Post $post): self
{
if ($this->posts->contains($post)) {
$this->posts->removeElement($post);
$post->removeAttachment($this);
}
return $this;
}
public function __toString(): string
{
return (string) $this->display_name;
}
}