src/Entity/ShareType.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ShareTypeRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Blameable\Traits\BlameableEntity;
  8. use Gedmo\Timestampable\Traits\TimestampableEntity;
  9. #[ORM\Entity(repositoryClassShareTypeRepository::class)]
  10. class ShareType extends BaseKeyValue
  11. {
  12.     use BlameableEntity//Hook blameable behavior. Updates createdBy, updatedBy fields
  13.     use TimestampableEntity//Hook timestampable behavior. Updates createdAt, updatedAt fields 
  14.     const ALL 'ALL';
  15.     const NONE 'NONE';
  16.     const FRIENDS 'FRIENDS';
  17.     #[ORM\Id]
  18.     #[ORM\GeneratedValue(strategy"IDENTITY")]
  19.     #[ORM\Column]
  20.     private ?int $id null;
  21.     
  22.     #[ORM\Column()]
  23.     private ?int $sort null;
  24.     #[ORM\OneToMany(mappedBy'shareFavouriteProductsType'targetEntityUser::class)]
  25.     private Collection $shareFavouriteProductUsers;
  26.     #[ORM\OneToMany(mappedBy'shareShoppingType'targetEntityUser::class)]
  27.     private Collection $shareShoppingUsers;
  28.     public function __construct()
  29.     {
  30.         $this->shareFavouriteProductUsers = new ArrayCollection();
  31.         $this->shareShoppingUsers = new ArrayCollection();
  32.     }
  33.     public function getId(): ?int
  34.     {
  35.         return $this->id;
  36.     }
  37.     public function getSort(): ?int
  38.     {
  39.         return $this->sort;
  40.     }
  41.     public function setSort(int $sort): self
  42.     {
  43.         $this->sort $sort;
  44.         return $this;
  45.     }
  46.     /**
  47.      * @return Collection<int, Product>
  48.      */
  49.     public function getShareFavouriteProductUsers(): Collection
  50.     {
  51.         return $this->shareFavouriteProductUsers;
  52.     }
  53.     public function addShareFavouriteProductUser(User $user): self
  54.     {
  55.         if (!$this->shareFavouriteProductUsers->contains($user)) {
  56.             $this->shareFavouriteProductUsers->add($user);
  57.             $user->setShareFavouriteProductsType($this);
  58.         }
  59.         return $this;
  60.     }
  61.     public function removeShareFavouriteProductUser(User $user): self
  62.     {
  63.         if ($this->shareFavouriteProductUsers->removeElement($user)) {
  64.             // set the owning side to null (unless already changed)
  65.             if ($user->getShareFavouriteProductsType() === $this) {
  66.                 $user->setShareFavouriteProductsType(null);
  67.             }
  68.         }
  69.         return $this;
  70.     }
  71.     /**
  72.      * @return Collection<int, User>
  73.      */
  74.     public function getShareShoppingUsers(): Collection
  75.     {
  76.         return $this->shareShoppingUsers;
  77.     }
  78.     public function addShareShoppingUser(User $user): self
  79.     {
  80.         if (!$this->shareShoppingUsers->contains($user)) {
  81.             $this->shareShoppingUsers->add($user);
  82.             $user->setShareShoppingType($this);
  83.         }
  84.         return $this;
  85.     }
  86.     public function removeShareShoppingUser(User $user): self
  87.     {
  88.         if ($this->shareShoppingUsers->removeElement($user)) {
  89.             // set the owning side to null (unless already changed)
  90.             if ($user->getShareShoppingType() === $this) {
  91.                 $user->setShareShoppingType(null);
  92.             }
  93.         }
  94.         return $this;
  95.     }
  96. }