src/Entity/CRM/SocialPost.php line 12
<?phpnamespace App\Entity\CRM;use App\Repository\CRM\SocialPostRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: SocialPostRepository::class)]class SocialPost{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\Column(length: 255)]private ?string $title = null;#[ORM\Column(type: Types::TEXT, nullable: true)]private ?string $content = null;#[ORM\Column(length: 500, nullable: true)]private ?string $image = null;#[ORM\Column(nullable: true)]private ?bool $accepted = false;#[ORM\Column(nullable: true)]private ?bool $isActive = true;#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]private ?\DateTimeInterface $dateForPublish = null;#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]private ?\DateTimeInterface $createdAt = null;#[ORM\ManyToOne]#[ORM\JoinColumn(nullable: true)]private ?Admin $acceptedBy = null;#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]private ?\DateTimeInterface $acceptedAt = null;#[ORM\Column(nullable: true, options: ['default' => false])]private ?bool $addToWebsite = false;#[ORM\Column(nullable: true, options: ['default' => false])]private ?bool $publishedOnWebsite = false;#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]private ?\DateTimeInterface $websitePublishedAt = null;#[ORM\OneToMany(mappedBy: 'socialPost', targetEntity: SocialPostPlatform::class, cascade: ['persist', 'remove'], orphanRemoval: true)]private Collection $socialPostPlatforms;public function __construct(){$this->socialPostPlatforms = new ArrayCollection();$this->createdAt = new \DateTime();}public function __toString(): string{return $this->title ?? '';}public function getId(): ?int{return $this->id;}public function getTitle(): ?string{return $this->title;}public function setTitle(string $title): static{$this->title = $title;return $this;}public function getContent(): ?string{return $this->content;}public function setContent(?string $content): static{$this->content = $content;return $this;}public function getImage(): ?string{return $this->image;}public function setImage(?string $image): static{$this->image = $image;return $this;}public function isAccepted(): ?bool{return $this->accepted;}public function setAccepted(?bool $accepted): static{$this->accepted = $accepted;return $this;}public function isIsActive(): ?bool{return $this->isActive;}public function setIsActive(?bool $isActive): static{$this->isActive = $isActive;return $this;}public function getDateForPublish(): ?\DateTimeInterface{return $this->dateForPublish;}public function setDateForPublish(?\DateTimeInterface $dateForPublish): static{$this->dateForPublish = $dateForPublish;return $this;}public function getCreatedAt(): ?\DateTimeInterface{return $this->createdAt;}public function setCreatedAt(?\DateTimeInterface $createdAt): static{$this->createdAt = $createdAt;return $this;}public function getAcceptedBy(): ?Admin{return $this->acceptedBy;}public function setAcceptedBy(?Admin $acceptedBy): static{$this->acceptedBy = $acceptedBy;return $this;}public function getAcceptedAt(): ?\DateTimeInterface{return $this->acceptedAt;}public function setAcceptedAt(?\DateTimeInterface $acceptedAt): static{$this->acceptedAt = $acceptedAt;return $this;}public function isAddToWebsite(): ?bool{return $this->addToWebsite;}public function setAddToWebsite(?bool $addToWebsite): static{$this->addToWebsite = $addToWebsite;return $this;}public function isPublishedOnWebsite(): ?bool{return $this->publishedOnWebsite;}public function setPublishedOnWebsite(?bool $publishedOnWebsite): static{$this->publishedOnWebsite = $publishedOnWebsite;return $this;}public function getWebsitePublishedAt(): ?\DateTimeInterface{return $this->websitePublishedAt;}public function setWebsitePublishedAt(?\DateTimeInterface $websitePublishedAt): static{$this->websitePublishedAt = $websitePublishedAt;return $this;}/*** @return Collection<int, SocialPostPlatform>*/public function getSocialPostPlatforms(): Collection{return $this->socialPostPlatforms;}public function addSocialPostPlatform(SocialPostPlatform $socialPostPlatform): static{if (!$this->socialPostPlatforms->contains($socialPostPlatform)) {$this->socialPostPlatforms->add($socialPostPlatform);$socialPostPlatform->setSocialPost($this);}return $this;}public function removeSocialPostPlatform(SocialPostPlatform $socialPostPlatform): static{if ($this->socialPostPlatforms->removeElement($socialPostPlatform)) {if ($socialPostPlatform->getSocialPost() === $this) {$socialPostPlatform->setSocialPost(null);}}return $this;}public function isPublishedOnAll(): bool{if ($this->socialPostPlatforms->isEmpty() && !$this->addToWebsite) {return false;}if ($this->addToWebsite && !$this->publishedOnWebsite) {return false;}foreach ($this->socialPostPlatforms as $spp) {if (!$spp->isPublished()) {return false;}}return true;}}