<?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 App\Repository\TaxRuleCountryRepository;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use App\DoctrineExtensions\Timestampable\Traits\UserTimestampableEntity;
use App\DoctrineExtensions\SoftDeleteable\Traits\UserSoftDeleteableEntity;
/**
* @ORM\Entity(repositoryClass=TaxRuleCountryRepository::class)
* @ORM\Table(name="tax_rule_country", 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={"tax_rule", "tax", "country"},
* errorPath="tax_rule",
* message="This association between the tax and the country already exists for this tax rule.",
* ignoreNull=false
* )
*/
class TaxRuleCountry implements \JsonSerializable
{
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=TaxRule::class, inversedBy="taxRuleCountries")
* @ORM\JoinColumn(nullable=false)
*/
private TaxRule $tax_rule;
/**
* @ORM\ManyToOne(targetEntity=Tax::class, inversedBy="taxRuleCountries")
* @ORM\JoinColumn(nullable=false)
*/
private Tax $tax;
/**
* @ORM\ManyToOne(targetEntity=Country::class, inversedBy="taxRuleCountries")
* @ORM\JoinColumn(nullable=false)
*/
private Country $country;
/**
* @return Uuid|null
*/
public function getId(): ?Uuid
{
return $this->id;
}
/**
* @return TaxRule
*/
public function getTaxRule(): TaxRule
{
return $this->tax_rule;
}
/**
* @param TaxRule $tax_rule
* @return $this
*/
public function setTaxRule(TaxRule $tax_rule): self
{
$this->tax_rule = $tax_rule;
return $this;
}
/**
* @return Tax
*/
public function getTax(): Tax
{
return $this->tax;
}
/**
* @param Tax $tax
* @return $this
*/
public function setTax(Tax $tax): self
{
$this->tax = $tax;
return $this;
}
/**
* @return Country
*/
public function getCountry(): Country
{
return $this->country;
}
/**
* @param Country $country
* @return $this
*/
public function setCountry(Country $country): self
{
$this->country = $country;
return $this;
}
/**
* @return mixed
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return [
'id' => $this->id,
'tax_rule' => $this->tax_rule,
'tax' => $this->tax,
'country' => $this->country
];
}
}