src/Entity/TeamUser.php line 39

Open in your IDE?
  1. <?php
  2. /**
  3.  * @author Leo BANNHOLTZER (contact@scaledev.fr)
  4.  * @copyright 2021 - ScaleDEV SAS, 12 RUE CHARLES MORET, 10120 ST ANDRE LES VERGERS
  5.  * @license commercial
  6.  */
  7. declare(strict_types=1);
  8. namespace App\Entity;
  9. use Symfony\Component\Uid\Uuid;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Gedmo\Mapping\Annotation as Gedmo;
  12. use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
  13. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  14. use App\Repository\TeamUserRepository;
  15. use App\DoctrineExtensions\Timestampable\Traits\UserTimestampableEntity;
  16. use App\DoctrineExtensions\SoftDeleteable\Traits\UserSoftDeleteableEntity;
  17. use App\Entity\Team;
  18. use App\Entity\User;
  19. /**
  20.  * @ORM\Entity(repositoryClass=TeamUserRepository::class)
  21.  * @ORM\Table(name="team_user", indexes={
  22.  *  @ORM\Index(name="deleted_at", columns={"deleted_at"}),
  23.  *  @ORM\Index(name="created_at", columns={"created_at"}),
  24.  *  @ORM\Index(name="updated_at", columns={"updated_at"})
  25.  * })
  26.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=false)
  27.  * @UniqueEntity(
  28.  *     fields={"team", "user"},
  29.  *     errorPath="team",
  30.  *     message="This association between this team and this user already exists.",
  31.  *     ignoreNull=false
  32.  * )
  33.  */
  34. class TeamUser
  35. {
  36.     use UserTimestampableEntity;
  37.     use UserSoftDeleteableEntity;
  38.     /**
  39.      * @ORM\Id
  40.      * @ORM\Column(type="uuid")
  41.      * @ORM\GeneratedValue(strategy="CUSTOM")
  42.      * @ORM\CustomIdGenerator(class=UuidGenerator::class)
  43.      */
  44.     private ?Uuid $id null;
  45.     /**
  46.      * @ORM\ManyToOne(targetEntity=Team::class, inversedBy="teamUsers")
  47.      * @ORM\JoinColumn(nullable=false)
  48.      */
  49.     private Team $team;
  50.     /**
  51.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="teamUsers")
  52.      * @ORM\JoinColumn(nullable=false)
  53.      */
  54.     private User $user;
  55.     /**
  56.      * @return Uuid|null
  57.      */
  58.     public function getId(): ?Uuid
  59.     {
  60.         return $this->id;
  61.     }
  62.     /**
  63.      * @return Team
  64.      */
  65.     public function getTeam(): ?Team
  66.     {
  67.         return $this->team;
  68.     }
  69.     /**
  70.      * @param Team $team
  71.      * @return $this
  72.      */
  73.     public function setTeam(?Team $team): self
  74.     {
  75.         $this->team $team;
  76.         return $this;
  77.     }
  78.     /**
  79.      * @return User
  80.      */
  81.     public function getUser(): ?User
  82.     {
  83.         return $this->user;
  84.     }
  85.     /**
  86.      * @param User $user
  87.      * @return $this
  88.      */
  89.     public function setUser(User $user): self
  90.     {
  91.         $this->user $user;
  92.         return $this;
  93.     }
  94. }