Created
June 9, 2020 08:23
-
-
Save erop/eb32da8e3a07073ea4070ee0495be036 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace App\Entity; | |
use ApiPlatform\Core\Annotation\ApiResource; | |
use DateTimeImmutable; | |
use Doctrine\Common\Collections\ArrayCollection; | |
use Doctrine\Common\Collections\Collection; | |
use Doctrine\ORM\Mapping as ORM; | |
use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity; | |
use Gedmo\Timestampable\Traits\TimestampableEntity; | |
use libphonenumber\PhoneNumber; | |
use Misd\PhoneNumberBundle\Validator\Constraints\PhoneNumber as AssertPhoneNumber; | |
use MyVendor\Contracts\Document\DrivingPermission; | |
use MyVendor\Contracts\Document\PersonIdentity; | |
use MyVendor\Contracts\Entity\DocumentInterface; | |
use MyVendor\Contracts\Entity\InsurantInterface; | |
use MyVendor\Contracts\Entity\PersonInterface; | |
use MyVendor\Contracts\Entity\VehicleOwnerInterface; | |
use MyVendor\Contracts\Enums\AddressTypes; | |
use Ramsey\Uuid\Uuid; | |
use Ramsey\Uuid\UuidInterface; | |
use Symfony\Component\Serializer\Annotation\Groups; | |
/** | |
* @ApiResource( | |
* normalizationContext={"groups"={"person:read"}}, | |
* denormalizationContext={"groups"={"person:write"}} | |
* ) | |
* @ORM\Entity(repositoryClass="App\Repository\PersonRepository") | |
* @ORM\Table(name="persons") | |
*/ | |
class Person implements PersonInterface, VehicleOwnerInterface, InsurantInterface | |
{ | |
use TimestampableEntity; | |
use SoftDeleteableEntity; | |
use DocumentCollectionTrait; | |
/** | |
* @ORM\Id() | |
* @ORM\Column(type="uuid", unique=true) | |
* @Groups({"person:read", "person:write"}) | |
*/ | |
private UuidInterface $id; | |
/** | |
* @ORM\Column(type="string", nullable=false) | |
* @Groups({"person:read", "person:write", "vehicle:write"}) | |
*/ | |
private string $firstName; | |
public function __construct(string $firstName) | |
{ | |
$this->id = Uuid::uuid4(); | |
$this->documents = new ArrayCollection(); | |
$this->firstName = $firstName; | |
$this->addresses = new ArrayCollection(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment