svg
This commit is contained in:
@ -7,10 +7,11 @@ use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
#[ORM\Entity(repositoryClass: AccountingRepository::class)]
|
||||
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_ACCOUNTING', fields: ['num01', 'num02'])]
|
||||
#[UniqueEntity(fields: ['num01', 'num02'], message: 'Ce numéro de compte est déjà utilisé.')]
|
||||
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_ACCOUNTING', fields: ['company', 'num01', 'num02'])]
|
||||
#[UniqueEntity(fields: ['company', 'num01', 'num02'], message: 'Ce numéro de compte est déjà utilisé.')]
|
||||
class Accounting
|
||||
{
|
||||
#[ORM\Id]
|
||||
@ -18,10 +19,18 @@ class Accounting
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
#[ORM\Column(length: 3)]
|
||||
#[Assert\Regex(
|
||||
pattern: '/^[0-9]{3}$/',
|
||||
message: 'La valeur doit être un nombre de trois chiffres (ex: 001, 098, 540).'
|
||||
)]
|
||||
private ?string $num01 = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
#[ORM\Column(length: 10)]
|
||||
#[Assert\Regex(
|
||||
pattern: '/^[0-9]{3}$/',
|
||||
message: 'La valeur doit être un nombre de trois chiffres (ex: 001, 098, 540).'
|
||||
)]
|
||||
private ?string $num02 = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
@ -67,7 +76,7 @@ class Accounting
|
||||
|
||||
public function setNum01(string $num01): static
|
||||
{
|
||||
$this->num01 = $num01;
|
||||
$this->num01 = str_pad($num01, 3, '0', STR_PAD_LEFT);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@ -79,7 +88,7 @@ class Accounting
|
||||
|
||||
public function setNum02(string $num02): static
|
||||
{
|
||||
$this->num02 = $num02;
|
||||
$this->num02 = str_pad($num02, 3, '0', STR_PAD_LEFT);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ 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'])]
|
||||
@ -22,12 +23,16 @@ class Company
|
||||
#[ORM\Column(length: 255, unique: true)]
|
||||
private ?string $title = null;
|
||||
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
||||
private ?string $adress = 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;
|
||||
|
||||
@ -87,6 +92,30 @@ class Company
|
||||
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;
|
||||
@ -99,18 +128,6 @@ class Company
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLogo(): ?string
|
||||
{
|
||||
return $this->logo;
|
||||
}
|
||||
|
||||
public function setLogo(?string $logo): static
|
||||
{
|
||||
$this->logo = $logo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBankname(): ?string
|
||||
{
|
||||
return $this->bankname;
|
||||
|
@ -46,6 +46,10 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
#[ORM\ManyToMany(targetEntity: Company::class, inversedBy: 'users')]
|
||||
private Collection $companys;
|
||||
|
||||
#[ORM\ManyToOne()]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
private ?Company $company = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->companys = new ArrayCollection();
|
||||
@ -173,4 +177,20 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCompany(): ?Company
|
||||
{
|
||||
if (!$this->companys) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->company;
|
||||
}
|
||||
|
||||
public function setCompany(?Company $company): static
|
||||
{
|
||||
$this->company = $company;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user