src/Entity/Image.php line 14

  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Timestamps;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use App\Repository\ImageRepository;
  6. use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator;
  7. use Symfony\Component\Uid\Ulid;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. #[ORM\Entity(repositoryClassImageRepository::class)]
  10. #[Gedmo\SoftDeleteable(fieldName'deletedAt'timeAwarefalsehardDeletetrue)]
  11. class Image
  12. {
  13.     use Timestamps;
  14.     #[ORM\Id]
  15.     #[ORM\Column(type'ulid'uniquetrue)]
  16.     #[ORM\GeneratedValue(strategy"CUSTOM")]
  17.     #[ORM\CustomIdGenerator(class: UlidGenerator::class)]
  18.     private ?Ulid $id null;
  19.     #[ORM\Column(type'string'length255)]
  20.     private $url;
  21.     #[ORM\Column(type'string'length255)]
  22.     private $alt;
  23.     #[ORM\ManyToOne(targetEntityPost::class, inversedBy'images')]
  24.     #[ORM\JoinColumn(nullablefalse)]
  25.     private $post;
  26.     public function __construct()
  27.     {
  28.         $this->alt "Clever Nursery";
  29.     }
  30.     public function getId(): ?Ulid
  31.     {
  32.         return $this->id;
  33.     }
  34.     public function getUrl(): ?string
  35.     {
  36.         return $this->url;
  37.     }
  38.     public function setUrl(string $url): self
  39.     {
  40.         $this->url $url;
  41.         return $this;
  42.     }
  43.     public function getAlt(): ?string
  44.     {
  45.         return $this->alt;
  46.     }
  47.     public function setAlt(string $alt): self
  48.     {
  49.         $this->alt $alt;
  50.         return $this;
  51.     }
  52.     public function getPost(): ?Post
  53.     {
  54.         return $this->post;
  55.     }
  56.     public function setPost(?Post $post): self
  57.     {
  58.         $this->post $post;
  59.         return $this;
  60.     }
  61. }