src/Entity/Croplist.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CroplistRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassCroplistRepository::class)]
  9. class Croplist
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\ManyToOne(inversedBy'cropLists')]
  16.     #[ORM\JoinColumn(nullablefalse)]
  17.     private ?User $user null;
  18.     #[ORM\Column(length100nullabletrue)]
  19.     private ?string $name null;
  20.     #[ORM\OneToMany(mappedBy'croplist'targetEntityFavoriteCrop::class)]
  21.     private Collection $favoriteCrops;
  22.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  23.     private ?\DateTimeInterface $created_at null;
  24.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  25.     private ?\DateTimeInterface $updated_at null;
  26.     public function __construct()
  27.     {
  28.         $this->favoriteCrops = new ArrayCollection();
  29.         $this->created_at = new \DateTime();
  30.     }
  31.     public function getId(): ?int
  32.     {
  33.         return $this->id;
  34.     }
  35.     public function getUser(): ?User
  36.     {
  37.         return $this->user;
  38.     }
  39.     public function setUser(?User $user): self
  40.     {
  41.         $this->user $user;
  42.         return $this;
  43.     }
  44.     public function getName(): ?string
  45.     {
  46.         return $this->name;
  47.     }
  48.     public function setName(?string $name): self
  49.     {
  50.         $this->name $name;
  51.         return $this;
  52.     }
  53.     /**
  54.      * @return Collection<int, FavoriteCrop>
  55.      */
  56.     public function getFavoriteCrops(): Collection
  57.     {
  58.         return $this->favoriteCrops;
  59.     }
  60.     public function addFavoriteCrop(FavoriteCrop $favoriteCrop): self
  61.     {
  62.         if (!$this->favoriteCrops->contains($favoriteCrop)) {
  63.             $this->favoriteCrops->add($favoriteCrop);
  64.             $favoriteCrop->setCroplist($this);
  65.         }
  66.         return $this;
  67.     }
  68.     public function removeFavoriteCrop(FavoriteCrop $favoriteCrop): self
  69.     {
  70.         if ($this->favoriteCrops->removeElement($favoriteCrop)) {
  71.             // set the owning side to null (unless already changed)
  72.             if ($favoriteCrop->getCroplist() === $this) {
  73.                 $favoriteCrop->setCroplist(null);
  74.             }
  75.         }
  76.         return $this;
  77.     }
  78.     public function getCreatedAt(): ?\DateTimeInterface
  79.     {
  80.         return $this->created_at;
  81.     }
  82.     public function setCreatedAt(\DateTimeInterface $created_at): self
  83.     {
  84.         $this->created_at $created_at;
  85.         return $this;
  86.     }
  87.     public function getUpdatedAt(): ?\DateTimeInterface
  88.     {
  89.         return $this->updated_at;
  90.     }
  91.     public function setUpdatedAt(?\DateTimeInterface $updated_at): self
  92.     {
  93.         $this->updated_at $updated_at;
  94.         return $this;
  95.     }
  96. }