312 lines
7.2 KiB
PHP
312 lines
7.2 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use App\Repository\OrganizationsRepository;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
#[ORM\Entity(repositoryClass: OrganizationsRepository::class)]
|
|
#[ORM\UniqueConstraint(name: 'UNIQ_ORGANIZATION_EMAIL', fields: ['email'])]
|
|
#[UniqueEntity(fields: ['email'], message: 'Une organisation avec cet email existe déjà.')]
|
|
class Organizations
|
|
{
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue]
|
|
#[ORM\Column]
|
|
private ?int $id = null;
|
|
|
|
#[ORM\Column(length: 255)]
|
|
private ?string $email = null;
|
|
|
|
#[ORM\Column]
|
|
private ?int $number = null;
|
|
|
|
#[ORM\Column(length: 255)]
|
|
private ?string $address = null;
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
private ?string $logo_url = null;
|
|
|
|
#[ORM\Column(options: ['default' => 'CURRENT_TIMESTAMP'])]
|
|
private ?\DateTimeImmutable $createdAt = null;
|
|
|
|
#[ORM\Column(options: ['default' => false])]
|
|
private ?bool $isDeleted = false;
|
|
|
|
#[ORM\Column(options: ['default' => true])]
|
|
private ?bool $isActive = true;
|
|
|
|
/**
|
|
* @var Collection<int, Apps>
|
|
*/
|
|
#[ORM\ManyToMany(targetEntity: Apps::class, mappedBy: 'organization')]
|
|
private Collection $apps;
|
|
|
|
#[ORM\Column(length: 255)]
|
|
#[Assert\NotBlank(message: "Le nom ne peut pas être vide.")]
|
|
private ?string $name = null;
|
|
|
|
/**
|
|
* @var Collection<int, Actions>
|
|
*/
|
|
#[ORM\OneToMany(targetEntity: Actions::class, mappedBy: 'Organization')]
|
|
private Collection $actions;
|
|
|
|
/**
|
|
* @var Collection<int, UserOrganizationApp>
|
|
*/
|
|
#[ORM\OneToMany(targetEntity: UserOrganizationApp::class, mappedBy: 'organization')]
|
|
private Collection $userOrganizatonApps;
|
|
|
|
#[ORM\Column(length: 4, nullable: true)]
|
|
private ?string $projectPrefix = null;
|
|
|
|
/**
|
|
* @var Collection<int, Project>
|
|
*/
|
|
#[ORM\OneToMany(targetEntity: Project::class, mappedBy: 'organization')]
|
|
private Collection $projects;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->apps = new ArrayCollection();
|
|
$this->actions = new ArrayCollection();
|
|
$this->createdAt = new \DateTimeImmutable();
|
|
$this->userOrganizatonApps = new ArrayCollection();
|
|
$this->projects = new ArrayCollection();
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getEmail(): ?string
|
|
{
|
|
return $this->email;
|
|
}
|
|
|
|
public function setEmail(string $email): static
|
|
{
|
|
$this->email = $email;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getNumber(): ?int
|
|
{
|
|
return $this->number;
|
|
}
|
|
|
|
public function setNumber(int $number): static
|
|
{
|
|
$this->number = $number;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getAddress(): ?string
|
|
{
|
|
return $this->address;
|
|
}
|
|
|
|
public function setAddress(string $address): static
|
|
{
|
|
$this->address = $address;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getLogoUrl(): ?string
|
|
{
|
|
return $this->logo_url;
|
|
}
|
|
|
|
public function setLogoUrl(string $logo_url): static
|
|
{
|
|
$this->logo_url = $logo_url;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getCreatedAt(): ?\DateTimeImmutable
|
|
{
|
|
return $this->createdAt;
|
|
}
|
|
|
|
public function setCreatedAt(\DateTimeImmutable $createdAt): static
|
|
{
|
|
$this->createdAt = $createdAt;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function isDeleted(): ?bool
|
|
{
|
|
return $this->isDeleted;
|
|
}
|
|
|
|
public function setIsDeleted(bool $isDeleted): static
|
|
{
|
|
$this->isDeleted = $isDeleted;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function isActive(): ?bool
|
|
{
|
|
return $this->isActive;
|
|
}
|
|
|
|
public function setIsActive(bool $isActive): static
|
|
{
|
|
$this->isActive = $isActive;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, Apps>
|
|
*/
|
|
public function getApps(): Collection
|
|
{
|
|
return $this->apps;
|
|
}
|
|
|
|
public function addApp(Apps $app): static
|
|
{
|
|
if (!$this->apps->contains($app)) {
|
|
$this->apps->add($app);
|
|
$app->addOrganization($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeApp(Apps $app): static
|
|
{
|
|
if ($this->apps->removeElement($app)) {
|
|
$app->removeOrganization($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getName(): ?string
|
|
{
|
|
return $this->name;
|
|
}
|
|
|
|
public function setName(string $name): static
|
|
{
|
|
$this->name = $name;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, Actions>
|
|
*/
|
|
public function getActions(): Collection
|
|
{
|
|
return $this->actions;
|
|
}
|
|
|
|
public function addAction(Actions $action): static
|
|
{
|
|
if (!$this->actions->contains($action)) {
|
|
$this->actions->add($action);
|
|
$action->setOrganization($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeAction(Actions $action): static
|
|
{
|
|
if ($this->actions->removeElement($action)) {
|
|
// set the owning side to null (unless already changed)
|
|
if ($action->getOrganization() === $this) {
|
|
$action->setOrganization(null);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, UserOrganizationApp>
|
|
*/
|
|
public function getUserOrganizatonApps(): Collection
|
|
{
|
|
return $this->userOrganizatonApps;
|
|
}
|
|
|
|
public function addUserOrganizatonApp(UserOrganizationApp $userOrganizatonApp): static
|
|
{
|
|
if (!$this->userOrganizatonApps->contains($userOrganizatonApp)) {
|
|
$this->userOrganizatonApps->add($userOrganizatonApp);
|
|
$userOrganizatonApp->setOrganization($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeUserOrganizatonApp(UserOrganizationApp $userOrganizatonApp): static
|
|
{
|
|
if ($this->userOrganizatonApps->removeElement($userOrganizatonApp)) {
|
|
// set the owning side to null (unless already changed)
|
|
if ($userOrganizatonApp->getOrganization() === $this) {
|
|
$userOrganizatonApp->setOrganization(null);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getProjectPrefix(): ?string
|
|
{
|
|
return $this->projectPrefix;
|
|
}
|
|
|
|
public function setProjectPrefix(?string $projectPrefix): static
|
|
{
|
|
$this->projectPrefix = $projectPrefix;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, Project>
|
|
*/
|
|
public function getProjects(): Collection
|
|
{
|
|
return $this->projects;
|
|
}
|
|
|
|
public function addProject(Project $project): static
|
|
{
|
|
if (!$this->projects->contains($project)) {
|
|
$this->projects->add($project);
|
|
$project->setOrganization($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeProject(Project $project): static
|
|
{
|
|
if ($this->projects->removeElement($project)) {
|
|
// set the owning side to null (unless already changed)
|
|
if ($project->getOrganization() === $this) {
|
|
$project->setOrganization(null);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
}
|