358 lines
8.0 KiB
PHP
358 lines
8.0 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use App\Repository\CompanyRepository;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\DBAL\Types\Types;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
|
|
#[ORM\Entity(repositoryClass: CompanyRepository::class)]
|
|
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_COMPANY', fields: ['title'])]
|
|
#[UniqueEntity(fields: ['email'], message: 'Ce nom de companie est déjà utilisé.')]
|
|
class Company
|
|
{
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue]
|
|
#[ORM\Column]
|
|
private ?int $id = null;
|
|
|
|
#[ORM\Column(length: 255, unique: true)]
|
|
private ?string $title = null;
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
private ?string $logo = null;
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
#[Assert\Email(message: 'Veuillez entrer un email valide.')]
|
|
private ?string $email = null;
|
|
|
|
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
|
private ?string $adress = null;
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
private ?string $bankname = null;
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
private ?string $bankcode = null;
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
private ?string $bankguichet = null;
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
private ?string $banknum = null;
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
private ?string $bankkey = null;
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
private ?string $banklocality = null;
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
private ?string $bankiban = null;
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
private ?string $bankbic = null;
|
|
|
|
/**
|
|
* @var Collection<int, Accounting>
|
|
*/
|
|
#[ORM\OneToMany(targetEntity: Accounting::class, mappedBy: 'company', orphanRemoval: true)]
|
|
private Collection $accountings;
|
|
|
|
/**
|
|
* @var Collection<int, User>
|
|
*/
|
|
#[ORM\ManyToMany(targetEntity: User::class, mappedBy: 'companys')]
|
|
private Collection $users;
|
|
|
|
/**
|
|
* @var Collection<int, Year>
|
|
*/
|
|
#[ORM\OneToMany(targetEntity: Year::class, mappedBy: 'company', orphanRemoval: true)]
|
|
private Collection $years;
|
|
|
|
/**
|
|
* @var Collection<int, Operation>
|
|
*/
|
|
#[ORM\OneToMany(targetEntity: Operation::class, mappedBy: 'company', orphanRemoval: true)]
|
|
private Collection $operations;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->accountings = new ArrayCollection();
|
|
$this->users = new ArrayCollection();
|
|
$this->years = new ArrayCollection();
|
|
$this->operations = new ArrayCollection();
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getTitle(): ?string
|
|
{
|
|
return $this->title;
|
|
}
|
|
|
|
public function setTitle(string $title): static
|
|
{
|
|
$this->title = $title;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getLogo(): ?string
|
|
{
|
|
return $this->logo ? $this->logo : 'medias/logo/logo.png';
|
|
}
|
|
|
|
public function setLogo(?string $logo): static
|
|
{
|
|
$this->logo = $logo;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getEmail(): ?string
|
|
{
|
|
return $this->email;
|
|
}
|
|
|
|
public function setEmail(?string $email): static
|
|
{
|
|
$this->email = $email;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getAdress(): ?string
|
|
{
|
|
return $this->adress;
|
|
}
|
|
|
|
public function setAdress(?string $adress): static
|
|
{
|
|
$this->adress = $adress;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getBankname(): ?string
|
|
{
|
|
return $this->bankname;
|
|
}
|
|
|
|
public function setBankname(?string $bankname): static
|
|
{
|
|
$this->bankname = $bankname;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getBankcode(): ?string
|
|
{
|
|
return $this->bankcode;
|
|
}
|
|
|
|
public function setBankcode(?string $bankcode): static
|
|
{
|
|
$this->bankcode = $bankcode;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getBankguichet(): ?string
|
|
{
|
|
return $this->bankguichet;
|
|
}
|
|
|
|
public function setBankguichet(?string $bankguichet): static
|
|
{
|
|
$this->bankguichet = $bankguichet;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getBanknum(): ?string
|
|
{
|
|
return $this->banknum;
|
|
}
|
|
|
|
public function setBanknum(?string $banknum): static
|
|
{
|
|
$this->banknum = $banknum;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getBankkey(): ?string
|
|
{
|
|
return $this->bankkey;
|
|
}
|
|
|
|
public function setBankkey(?string $bankkey): static
|
|
{
|
|
$this->bankkey = $bankkey;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getBanklocality(): ?string
|
|
{
|
|
return $this->banklocality;
|
|
}
|
|
|
|
public function setBanklocality(?string $banklocality): static
|
|
{
|
|
$this->banklocality = $banklocality;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getBankiban(): ?string
|
|
{
|
|
return $this->bankiban;
|
|
}
|
|
|
|
public function setBankiban(?string $bankiban): static
|
|
{
|
|
$this->bankiban = $bankiban;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getBankbic(): ?string
|
|
{
|
|
return $this->bankbic;
|
|
}
|
|
|
|
public function setBankbic(?string $bankbic): static
|
|
{
|
|
$this->bankbic = $bankbic;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, Accounting>
|
|
*/
|
|
public function getAccountings(): Collection
|
|
{
|
|
return $this->accountings;
|
|
}
|
|
|
|
public function addAccounting(Accounting $accounting): static
|
|
{
|
|
if (!$this->accountings->contains($accounting)) {
|
|
$this->accountings->add($accounting);
|
|
$accounting->setCompany($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeAccounting(Accounting $accounting): static
|
|
{
|
|
if ($this->accountings->removeElement($accounting)) {
|
|
// set the owning side to null (unless already changed)
|
|
if ($accounting->getCompany() === $this) {
|
|
$accounting->setCompany(null);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, User>
|
|
*/
|
|
public function getUsers(): Collection
|
|
{
|
|
return $this->users;
|
|
}
|
|
|
|
public function addUser(User $user): static
|
|
{
|
|
if (!$this->users->contains($user)) {
|
|
$this->users->add($user);
|
|
$user->addCompany($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeUser(User $user): static
|
|
{
|
|
if ($this->users->removeElement($user)) {
|
|
$user->removeCompany($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, Year>
|
|
*/
|
|
public function getYears(): Collection
|
|
{
|
|
return $this->years;
|
|
}
|
|
|
|
public function addYear(Year $year): static
|
|
{
|
|
if (!$this->years->contains($year)) {
|
|
$this->years->add($year);
|
|
$year->setCompany($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeYear(Year $year): static
|
|
{
|
|
if ($this->years->removeElement($year)) {
|
|
// set the owning side to null (unless already changed)
|
|
if ($year->getCompany() === $this) {
|
|
$year->setCompany(null);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, Operation>
|
|
*/
|
|
public function getOperations(): Collection
|
|
{
|
|
return $this->operations;
|
|
}
|
|
|
|
public function addOperation(Operation $operation): static
|
|
{
|
|
if (!$this->operations->contains($operation)) {
|
|
$this->operations->add($operation);
|
|
$operation->setCompany($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeOperation(Operation $operation): static
|
|
{
|
|
if ($this->operations->removeElement($operation)) {
|
|
// set the owning side to null (unless already changed)
|
|
if ($operation->getCompany() === $this) {
|
|
$operation->setCompany(null);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
}
|