src/Entity/Gallery/Album.php line 21

  1. <?php
  2. namespace App\Entity\Gallery;
  3. use App\Entity\Common\File;
  4. use App\Entity\Traits\ActiveTrait;
  5. use App\Entity\Traits\TrackerFields;
  6. use App\Entity\Traits\UserCreatedInterface;
  7. use App\Entity\Traits\UserUpdatedInterface;
  8. use App\Model\Translation\TranslatableTrait;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Doctrine\DBAL\Types\Types;
  12. use Doctrine\ORM\Mapping as ORM;
  13. use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
  14. #[ORM\Table(name'gallery_album')]
  15. #[ORM\Entity(repositoryClass\App\Repository\Gallery\AlbumRepository::class)]
  16. #[ORM\HasLifecycleCallbacks]
  17. class Album implements UserCreatedInterfaceUserUpdatedInterfaceTranslatableInterface
  18. {
  19.     use TrackerFields;
  20.     use TranslatableTrait;
  21.     use ActiveTrait;
  22.     #[ORM\Id]
  23.     #[ORM\GeneratedValue(strategy'AUTO')]
  24.     #[ORM\Column(type'integer')]
  25.     private ?int $id;
  26.     #[ORM\Column(type'string'nullabletrue)]
  27.     private ?string $caption;
  28.     #[ORM\Column(type'integer')]
  29.     private int $weight 50;
  30.     #[ORM\ManyToOne(targetEntity\App\Entity\Gallery\Group::class, inversedBy'albums')]
  31.     #[ORM\JoinColumn(nullablefalse)]
  32.     private Group $group;
  33.     #[ORM\ManyToOne(targetEntity\App\Entity\Common\File::class, cascade: ['persist''remove'])]
  34.     #[ORM\JoinColumn(nullabletrue)]
  35.     private ?File $previewImage;
  36.     #[ORM\OneToMany(mappedBy'album'targetEntityPhoto::class)]
  37.     private Collection $photos;
  38.     #[ORM\Column(typeTypes::BOOLEANoptions: ["default" => true,])]
  39.     private bool $publish true;
  40.     public function __construct()
  41.     {
  42.         $this->photos = new ArrayCollection();
  43.     }
  44.     /**
  45.      * @return int|null
  46.      */
  47.     public function getId(): ?int
  48.     {
  49.         return $this->id;
  50.     }
  51.     /**
  52.      * @param int|null $id
  53.      */
  54.     public function setId(?int $id): void
  55.     {
  56.         $this->id $id;
  57.     }
  58.     /**
  59.      * @return int
  60.      */
  61.     public function getWeight(): int
  62.     {
  63.         return $this->weight;
  64.     }
  65.     /**
  66.      * @param int $weight
  67.      */
  68.     public function setWeight(int $weight): void
  69.     {
  70.         $this->weight $weight;
  71.     }
  72.     public function getPhotos(): Collection
  73.     {
  74.         return $this->photos;
  75.     }
  76.     public function setPhotos(Collection $photos): void
  77.     {
  78.         $this->photos $photos;
  79.     }
  80.     /**
  81.      * @return Group
  82.      */
  83.     public function getGroup(): Group
  84.     {
  85.         return $this->group;
  86.     }
  87.     /**
  88.      * @param Group $group
  89.      */
  90.     public function setGroup(Group $group): void
  91.     {
  92.         $this->group $group;
  93.     }
  94.     public function getPreviewImage(): ?File
  95.     {
  96.         return $this->previewImage;
  97.     }
  98.     public function setPreviewImage(?File $preview): void
  99.     {
  100.         $this->previewImage $preview;
  101.     }
  102.     public function isPublish(): bool
  103.     {
  104.         return $this->publish;
  105.     }
  106.     public function setPublish(bool $publish): void
  107.     {
  108.         $this->publish $publish;
  109.     }
  110. }