<?php
declare(strict_types=1);

namespace App\Entity\Booking;

use App\Entity\Core\File;
//use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

/**
 * Classe ... qui ...
 */
//#[Auditable]
#[ORM\Entity]
class Work
{
    #[ORM\Id]
    #[ORM\Column]
    #[ORM\GeneratedValue]
    private ?int $id = null;

    #[ORM\ManyToOne(inversedBy: 'work')]
    private Course $course;

    #[ORM\OneToMany(mappedBy: 'work',targetEntity: WorkByUser::class,  cascade: ['persist'], orphanRemoval: true)]
    private Collection $workByUsers;

    #[ORM\OneToMany(mappedBy: 'work',targetEntity: File::class,  orphanRemoval: true)]
    private Collection $files;

    public function __construct()
    {
        $this->workByUsers = new ArrayCollection();
        $this->files = new ArrayCollection();
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getCourse(): ?Course
    {
        return $this->course;
    }

    public function setCourse(?Course $course): self
    {
        $this->course = $course;

        return $this;
    }

    /**
     * @return Collection<int, WorkByUser>
     */
    public function getWorkByUsers(): Collection
    {
        return $this->workByUsers;
    }

    public function addWorkByUser(WorkByUser $workByUser): self
    {
        if (!$this->workByUsers->contains($workByUser)) {
            $this->workByUsers[] = $workByUser;
            $workByUser->setWork($this);
        }

        return $this;
    }

    public function removeWorkByUser(WorkByUser $workByUser): self
    {
        if ($this->workByUsers->removeElement($workByUser)) {
            // set the owning side to null (unless already changed)
            if ($workByUser->getWork() === $this) {
                $workByUser->setWork(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, File>
     */
    public function getFiles(): Collection
    {
        return $this->files;
    }

    public function addFile(File $file): self
    {
        if (!$this->files->contains($file)) {
            $this->files[] = $file;
            $file->setWork($this);
        }

        return $this;
    }

    public function removeFile(File $file): self
    {
        if ($this->files->removeElement($file)) {
            // set the owning side to null (unless already changed)
            if ($file->getWork() === $this) {
                $file->setWork(null);
            }
        }

        return $this;
    }
}