src/Entity/Season.php line 22
<?php
namespace App\Entity;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Uid\Ulid;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\SeasonRepository;
use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator;
use Symfony\Component\Serializer\Annotation\Groups;
use Gedmo\Mapping\Annotation as Gedmo;
#[ORM\Entity(repositoryClass: SeasonRepository::class)]
#[Gedmo\SoftDeleteable(fieldName: 'deletedAt', timeAware: false, hardDelete: true)]
#[ORM\HasLifecycleCallbacks]
#[ApiResource(
attributes: ["security" => "is_granted('IS_AUTHENTICATED_FULLY')"],
)]
class Season
{
use Timestamps;
#[ORM\Id]
#[ORM\Column(type: 'ulid', unique: true)]
#[ORM\GeneratedValue(strategy: "CUSTOM")]
#[ORM\CustomIdGenerator(class: UlidGenerator::class)]
#[Groups('read:season:basic')]
private ?Ulid $id = null;
#[ORM\Column(type: 'string', length: 255)]
#[Groups('read:season:basic')]
private $name;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups('read:season:basic')]
private $description;
#[ORM\Column(type: 'datetime')]
#[Groups('read:season:basic')]
private $start_date;
#[ORM\Column(type: 'datetime')]
#[Groups('read:season:basic')]
private $end_date;
#[ORM\ManyToOne(targetEntity: Company::class, inversedBy: 'seasons')]
#[ORM\JoinColumn(nullable: false)]
private $owner;
#[ORM\Column(type: 'boolean')]
private $is_active = false;
#[ORM\OneToMany(mappedBy: 'season', targetEntity: Subscription::class, orphanRemoval: true)]
private $subscriptions;
#[ORM\OneToMany(mappedBy: 'season', targetEntity: Classroom::class, orphanRemoval: true)]
private $classrooms;
#[ORM\OneToMany(mappedBy: 'season', targetEntity: Task::class, orphanRemoval: true)]
private $tasks;
#[ORM\OneToMany(mappedBy: 'season', targetEntity: Evenement::class, orphanRemoval: true)]
private $evenements;
#[ORM\OneToMany(mappedBy: 'season', targetEntity: Payment::class, orphanRemoval: true)]
private $payments;
#[ORM\OneToMany(mappedBy: 'season', targetEntity: Expense::class, orphanRemoval: true)]
private $expenses;
#[ORM\OneToMany(mappedBy: 'season', targetEntity: AbsenceEmployee::class, orphanRemoval: true)]
private $absenceEmployees;
#[ORM\OneToMany(mappedBy: 'season', targetEntity: Child::class, orphanRemoval: true)]
private $children;
#[ORM\OneToMany(mappedBy: 'season', targetEntity: FamilyMember::class, orphanRemoval: true)]
private $familyMembers;
#[ORM\OneToMany(mappedBy: 'season', targetEntity: Employee::class, orphanRemoval: true)]
private $employees;
#[ORM\OneToMany(mappedBy: 'season', targetEntity: Pointing::class, orphanRemoval: true)]
private $pointings;
function __construct()
{
$this->start_date = new DateTime();
$this->end_date = new DateTime();
$this->subscriptions = new ArrayCollection();
$this->classrooms = new ArrayCollection();
$this->tasks = new ArrayCollection();
$this->evenements = new ArrayCollection();
$this->payments = new ArrayCollection();
$this->expenses = new ArrayCollection();
$this->absenceChildren = new ArrayCollection();
$this->absenceEmployees = new ArrayCollection();
$this->children = new ArrayCollection();
$this->familyMembers = new ArrayCollection();
$this->employees = new ArrayCollection();
$this->pointings = new ArrayCollection();
}
public function __toString()
{
return $this->name;
}
public function getId(): ?Ulid
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getStartDate(): ?\DateTimeInterface
{
return $this->start_date;
}
public function setStartDate(\DateTimeInterface $start_date): self
{
$this->start_date = $start_date;
return $this;
}
public function getEndDate(): ?\DateTimeInterface
{
return $this->end_date;
}
public function setEndDate(\DateTimeInterface $end_date): self
{
$this->end_date = $end_date;
return $this;
}
public function getOwner(): ?Company
{
return $this->owner;
}
public function setOwner(?Company $owner): self
{
$this->owner = $owner;
return $this;
}
public function isIsActive(): ?bool
{
return $this->is_active;
}
public function setIsActive(bool $is_active): self
{
$this->is_active = $is_active;
return $this;
}
/**
* @return Collection<int, Subscription>
*/
public function getSubscriptions(): Collection
{
return $this->subscriptions;
}
public function addSubscription(Subscription $subscription): self
{
if (!$this->subscriptions->contains($subscription)) {
$this->subscriptions[] = $subscription;
$subscription->setSeason($this);
}
return $this;
}
public function removeSubscription(Subscription $subscription): self
{
if ($this->subscriptions->removeElement($subscription)) {
// set the owning side to null (unless already changed)
if ($subscription->getSeason() === $this) {
$subscription->setSeason(null);
}
}
return $this;
}
/**
* @return Collection<int, Classroom>
*/
public function getClassrooms(): Collection
{
return $this->classrooms;
}
public function addClassroom(Classroom $classroom): self
{
if (!$this->classrooms->contains($classroom)) {
$this->classrooms[] = $classroom;
$classroom->setSeason($this);
}
return $this;
}
public function removeClassroom(Classroom $classroom): self
{
if ($this->classrooms->removeElement($classroom)) {
// set the owning side to null (unless already changed)
if ($classroom->getSeason() === $this) {
$classroom->setSeason(null);
}
}
return $this;
}
/**
* @return Collection<int, Task>
*/
public function getTasks(): Collection
{
return $this->tasks;
}
public function addTask(Task $task): self
{
if (!$this->tasks->contains($task)) {
$this->tasks[] = $task;
$task->setSeason($this);
}
return $this;
}
public function removeTask(Task $task): self
{
if ($this->tasks->removeElement($task)) {
// set the owning side to null (unless already changed)
if ($task->getSeason() === $this) {
$task->setSeason(null);
}
}
return $this;
}
/**
* @return Collection<int, Evenement>
*/
public function getEvenements(): Collection
{
return $this->evenements;
}
public function addEvenement(Evenement $evenement): self
{
if (!$this->evenements->contains($evenement)) {
$this->evenements[] = $evenement;
$evenement->setSeason($this);
}
return $this;
}
public function removeEvenement(Evenement $evenement): self
{
if ($this->evenements->removeElement($evenement)) {
// set the owning side to null (unless already changed)
if ($evenement->getSeason() === $this) {
$evenement->setSeason(null);
}
}
return $this;
}
/**
* @return Collection<int, Payment>
*/
public function getPayments(): Collection
{
return $this->payments;
}
public function addPayment(Payment $payment): self
{
if (!$this->payments->contains($payment)) {
$this->payments[] = $payment;
$payment->setSeason($this);
}
return $this;
}
public function removePayment(Payment $payment): self
{
if ($this->payments->removeElement($payment)) {
// set the owning side to null (unless already changed)
if ($payment->getSeason() === $this) {
$payment->setSeason(null);
}
}
return $this;
}
/**
* @return Collection<int, Expense>
*/
public function getExpenses(): Collection
{
return $this->expenses;
}
public function addExpense(Expense $expense): self
{
if (!$this->expenses->contains($expense)) {
$this->expenses[] = $expense;
$expense->setSeason($this);
}
return $this;
}
public function removeExpense(Expense $expense): self
{
if ($this->expenses->removeElement($expense)) {
// set the owning side to null (unless already changed)
if ($expense->getSeason() === $this) {
$expense->setSeason(null);
}
}
return $this;
}
/**
* @return Collection<int, AbsenceEmployee>
*/
public function getAbsenceEmployees(): Collection
{
return $this->absenceEmployees;
}
public function addAbsenceEmployee(AbsenceEmployee $absenceEmployee): self
{
if (!$this->absenceEmployees->contains($absenceEmployee)) {
$this->absenceEmployees[] = $absenceEmployee;
$absenceEmployee->setSeason($this);
}
return $this;
}
public function removeAbsenceEmployee(AbsenceEmployee $absenceEmployee): self
{
if ($this->absenceEmployees->removeElement($absenceEmployee)) {
// set the owning side to null (unless already changed)
if ($absenceEmployee->getSeason() === $this) {
$absenceEmployee->setSeason(null);
}
}
return $this;
}
/**
* @return Collection<int, Child>
*/
public function getChildren(): Collection
{
return $this->children;
}
public function addChild(Child $child): self
{
if (!$this->children->contains($child)) {
$this->children[] = $child;
$child->setSeason($this);
}
return $this;
}
public function removeChild(Child $child): self
{
if ($this->children->removeElement($child)) {
// set the owning side to null (unless already changed)
if ($child->getSeason() === $this) {
$child->setSeason(null);
}
}
return $this;
}
/**
* @return Collection<int, FamilyMember>
*/
public function getFamilyMembers(): Collection
{
return $this->familyMembers;
}
public function addFamilyMember(FamilyMember $familyMember): self
{
if (!$this->familyMembers->contains($familyMember)) {
$this->familyMembers[] = $familyMember;
$familyMember->setSeason($this);
}
return $this;
}
public function removeFamilyMember(FamilyMember $familyMember): self
{
if ($this->familyMembers->removeElement($familyMember)) {
// set the owning side to null (unless already changed)
if ($familyMember->getSeason() === $this) {
$familyMember->setSeason(null);
}
}
return $this;
}
/**
* @return Collection<int, Employee>
*/
public function getEmployees(): Collection
{
return $this->employees;
}
public function addEmployee(Employee $employee): self
{
if (!$this->employees->contains($employee)) {
$this->employees[] = $employee;
$employee->setSeason($this);
}
return $this;
}
public function removeEmployee(Employee $employee): self
{
if ($this->employees->removeElement($employee)) {
// set the owning side to null (unless already changed)
if ($employee->getSeason() === $this) {
$employee->setSeason(null);
}
}
return $this;
}
/**
* @return Collection<int, Pointing>
*/
public function getPointings(): Collection
{
return $this->pointings;
}
public function addPointing(Pointing $pointing): self
{
if (!$this->pointings->contains($pointing)) {
$this->pointings[] = $pointing;
$pointing->setSeason($this);
}
return $this;
}
public function removePointing(Pointing $pointing): self
{
if ($this->pointings->removeElement($pointing)) {
// set the owning side to null (unless already changed)
if ($pointing->getSeason() === $this) {
$pointing->setSeason(null);
}
}
return $this;
}
}