<?phpnamespace App\Entity;use App\Repository\NewsCategoryRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use JMS\Serializer\Annotation\Groups;use App\Entity\Traits\Timestampable;#[ORM\HasLifecycleCallbacks]#[ORM\Entity(repositoryClass: NewsCategoryRepository::class)]class NewsCategory{ use Timestampable; #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] #[Groups(['getNews'])] private ?int $id = null; #[ORM\Column(length: 255)] #[Groups(['getNews'])] private ?string $name = null; #[ORM\OneToMany(mappedBy: 'newsCategory', targetEntity: News::class)] private Collection $news; #[ORM\ManyToOne(inversedBy: 'newsCategories', cascade: ["persist"])] #[ORM\JoinColumn(nullable: false)] private ?User $author = null; #[ORM\ManyToOne(inversedBy: 'newsCategoriesEdited', cascade: ["persist"])] private ?User $editor = null; #[ORM\ManyToOne(inversedBy: 'newsCategories')] #[ORM\JoinColumn(nullable: false)] private ?School $school = null; public function __construct() { $this->news = new ArrayCollection(); } public function __toString(): string { return $this->name; } public function getId(): ?int { return $this->id; } public function getName(): ?string { return $this->name; } public function setName(string $name): static { $this->name = $name; return $this; } /** * @return Collection<int, News> */ public function getNews(): Collection { return $this->news; } public function addNews(News $news): static { if (!$this->news->contains($news)) { $this->news->add($news); $news->setNewsCategory($this); } return $this; } public function removeNews(News $news): static { if ($this->news->removeElement($news)) { // set the owning side to null (unless already changed) if ($news->getNewsCategory() === $this) { $news->setNewsCategory(null); } } return $this; } public function getAuthor(): ?User { return $this->author; } public function setAuthor(?User $author): static { $this->author = $author; return $this; } public function getEditor(): ?User { return $this->editor; } public function setEditor(?User $editor): static { $this->editor = $editor; return $this; } public function getSchool(): ?School { return $this->school; } public function setSchool(?School $school): static { $this->school = $school; return $this; }}