src/Entity/Website/CostCategory.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Website;
  3. use App\Entity\Website\Website\Website;
  4. use App\Repository\Website\CostCategoryRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
  9. use App\Entity\BaseEntity;
  10. #[ORM\Entity(repositoryClassCostCategoryRepository::class)]
  11. class CostCategory extends BaseEntity
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\Column(type'guid'uniquetrue)]
  15.     #[ORM\GeneratedValue(strategy'CUSTOM')]
  16.     #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
  17.     private ?string $id null;
  18.     #[ORM\Column(length255)]
  19.     private ?string $title null;
  20.     #[ORM\OneToMany(mappedBy'costCategory'targetEntityCost::class)]
  21.     private Collection $costs;
  22.     #[ORM\ManyToOne(inversedBy'costCategories')]
  23.     #[ORM\JoinColumn(nullablefalse)]
  24.     private ?Website $website null;
  25.     public function __construct()
  26.     {
  27.         parent::__construct();
  28.         $this->costs = new ArrayCollection();
  29.     }
  30.     public function __toString():string
  31.     {
  32.         return $this->getTitle();
  33.     }
  34.     public function getId(): ?string
  35.     {
  36.         return $this->id;
  37.     }
  38.     public function getTitle(): ?string
  39.     {
  40.         return $this->title;
  41.     }
  42.     public function setTitle(string $title): static
  43.     {
  44.         $this->title $title;
  45.         return $this;
  46.     }
  47.     /**
  48.      * @return Collection<int, Cost>
  49.      */
  50.     public function getCosts(): Collection
  51.     {
  52.         return $this->costs;
  53.     }
  54.     public function addCost(Cost $cost): static
  55.     {
  56.         if (!$this->costs->contains($cost)) {
  57.             $this->costs->add($cost);
  58.             $cost->setCostCategory($this);
  59.         }
  60.         return $this;
  61.     }
  62.     public function removeCost(Cost $cost): static
  63.     {
  64.         if ($this->costs->removeElement($cost)) {
  65.             // set the owning side to null (unless already changed)
  66.             if ($cost->getCostCategory() === $this) {
  67.                 $cost->setCostCategory(null);
  68.             }
  69.         }
  70.         return $this;
  71.     }
  72.     public function getWebsite(): ?Website
  73.     {
  74.         return $this->website;
  75.     }
  76.     public function setWebsite(?Website $website): static
  77.     {
  78.         $this->website $website;
  79.         return $this;
  80.     }
  81. }