mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Feature: add constraint to ensure postal code uniqueness and track creation and update of postal code
This commit is contained in:
@@ -12,6 +12,11 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
use Chill\MainBundle\Doctrine\Model\Point;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
@@ -21,6 +26,10 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(
|
||||
* name="chill_main_postal_code",
|
||||
* uniqueConstraints={
|
||||
* @ORM\UniqueConstraint(name="postal_code_import_unicity", columns={"code", "refpostalcodeid", "postalcodesource"},
|
||||
* options={"where": "refpostalcodeid is not null"})
|
||||
* },
|
||||
* indexes={
|
||||
* @ORM\Index(name="search_name_code", columns={"code", "label"}),
|
||||
* @ORM\Index(name="search_by_reference_code", columns={"code", "refpostalcodeid"})
|
||||
@@ -28,8 +37,12 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
||||
*
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*/
|
||||
class PostalCode
|
||||
class PostalCode implements TrackUpdateInterface, TrackCreationInterface
|
||||
{
|
||||
use TrackCreationTrait;
|
||||
|
||||
use TrackUpdateTrait;
|
||||
|
||||
/**
|
||||
* This is an internal column which is populated by database.
|
||||
*
|
||||
@@ -63,6 +76,11 @@ class PostalCode
|
||||
*/
|
||||
private $country;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable", nullable=true, options={"default": null})
|
||||
*/
|
||||
private ?DateTimeImmutable $deletedAt = null;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
|
Reference in New Issue
Block a user