<?php
/**
* @author Leo BANNHOLTZER (contact@scaledev.fr)
* @copyright 2021 - ScaleDEV SAS, 12 RUE CHARLES MORET, 10120 ST ANDRE LES VERGERS
* @license commercial
*/
declare(strict_types=1);
namespace App\Entity;
use Symfony\Component\Uid\Uuid;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use App\Repository\TeamUserRepository;
use App\DoctrineExtensions\Timestampable\Traits\UserTimestampableEntity;
use App\DoctrineExtensions\SoftDeleteable\Traits\UserSoftDeleteableEntity;
use App\Entity\Team;
use App\Entity\User;
/**
* @ORM\Entity(repositoryClass=TeamUserRepository::class)
* @ORM\Table(name="team_user", indexes={
* @ORM\Index(name="deleted_at", columns={"deleted_at"}),
* @ORM\Index(name="created_at", columns={"created_at"}),
* @ORM\Index(name="updated_at", columns={"updated_at"})
* })
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=false)
* @UniqueEntity(
* fields={"team", "user"},
* errorPath="team",
* message="This association between this team and this user already exists.",
* ignoreNull=false
* )
*/
class TeamUser
{
use UserTimestampableEntity;
use UserSoftDeleteableEntity;
/**
* @ORM\Id
* @ORM\Column(type="uuid")
* @ORM\GeneratedValue(strategy="CUSTOM")
* @ORM\CustomIdGenerator(class=UuidGenerator::class)
*/
private ?Uuid $id = null;
/**
* @ORM\ManyToOne(targetEntity=Team::class, inversedBy="teamUsers")
* @ORM\JoinColumn(nullable=false)
*/
private Team $team;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="teamUsers")
* @ORM\JoinColumn(nullable=false)
*/
private User $user;
/**
* @return Uuid|null
*/
public function getId(): ?Uuid
{
return $this->id;
}
/**
* @return Team
*/
public function getTeam(): ?Team
{
return $this->team;
}
/**
* @param Team $team
* @return $this
*/
public function setTeam(?Team $team): self
{
$this->team = $team;
return $this;
}
/**
* @return User
*/
public function getUser(): ?User
{
return $this->user;
}
/**
* @param User $user
* @return $this
*/
public function setUser(User $user): self
{
$this->user = $user;
return $this;
}
}