diff --git a/src/Module/Directory/Domain/Entity/Contact.php b/src/Module/Directory/Domain/Entity/Contact.php new file mode 100644 index 0000000..0f9e1d5 --- /dev/null +++ b/src/Module/Directory/Domain/Entity/Contact.php @@ -0,0 +1,183 @@ + ['contact:read']], + denormalizationContext: ['groups' => ['contact:write']], + order: ['lastName' => 'ASC'], +)] +#[ApiFilter(SearchFilter::class, properties: ['client' => 'exact', 'prospect' => 'exact'])] +#[ORM\Entity(repositoryClass: DoctrineContactRepository::class)] +#[ORM\Table(name: 'directory_contact')] +class Contact implements TimestampableInterface, BlamableInterface +{ + use TimestampableBlamableTrait; + + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column] + #[Groups(['contact:read'])] + private ?int $id = null; + + #[ORM\Column(length: 255, nullable: true)] + #[Groups(['contact:read', 'contact:write', 'client:read', 'prospect:read'])] + private ?string $firstName = null; + + #[ORM\Column(length: 255, nullable: true)] + #[Groups(['contact:read', 'contact:write', 'client:read', 'prospect:read'])] + private ?string $lastName = null; + + #[ORM\Column(length: 255, nullable: true)] + #[Groups(['contact:read', 'contact:write', 'client:read', 'prospect:read'])] + private ?string $jobTitle = null; + + #[ORM\Column(length: 255, nullable: true)] + #[Groups(['contact:read', 'contact:write', 'client:read', 'prospect:read'])] + private ?string $email = null; + + #[ORM\Column(length: 50, nullable: true)] + #[Groups(['contact:read', 'contact:write', 'client:read', 'prospect:read'])] + private ?string $phonePrimary = null; + + #[ORM\Column(length: 50, nullable: true)] + #[Groups(['contact:read', 'contact:write', 'client:read', 'prospect:read'])] + private ?string $phoneSecondary = null; + + #[ORM\ManyToOne(targetEntity: Client::class)] + #[ORM\JoinColumn(name: 'client_id', referencedColumnName: 'id', nullable: true, onDelete: 'CASCADE')] + #[Groups(['contact:read', 'contact:write'])] + private ?Client $client = null; + + #[ORM\ManyToOne(targetEntity: Prospect::class)] + #[ORM\JoinColumn(name: 'prospect_id', referencedColumnName: 'id', nullable: true, onDelete: 'CASCADE')] + #[Groups(['contact:read', 'contact:write'])] + private ?Prospect $prospect = null; + + public function getId(): ?int + { + return $this->id; + } + + public function getFirstName(): ?string + { + return $this->firstName; + } + + public function setFirstName(?string $firstName): static + { + $this->firstName = $firstName; + + return $this; + } + + public function getLastName(): ?string + { + return $this->lastName; + } + + public function setLastName(?string $lastName): static + { + $this->lastName = $lastName; + + return $this; + } + + public function getJobTitle(): ?string + { + return $this->jobTitle; + } + + public function setJobTitle(?string $jobTitle): static + { + $this->jobTitle = $jobTitle; + + return $this; + } + + public function getEmail(): ?string + { + return $this->email; + } + + public function setEmail(?string $email): static + { + $this->email = $email; + + return $this; + } + + public function getPhonePrimary(): ?string + { + return $this->phonePrimary; + } + + public function setPhonePrimary(?string $phonePrimary): static + { + $this->phonePrimary = $phonePrimary; + + return $this; + } + + public function getPhoneSecondary(): ?string + { + return $this->phoneSecondary; + } + + public function setPhoneSecondary(?string $phoneSecondary): static + { + $this->phoneSecondary = $phoneSecondary; + + return $this; + } + + public function getClient(): ?Client + { + return $this->client; + } + + public function setClient(?Client $client): static + { + $this->client = $client; + + return $this; + } + + public function getProspect(): ?Prospect + { + return $this->prospect; + } + + public function setProspect(?Prospect $prospect): static + { + $this->prospect = $prospect; + + return $this; + } +} diff --git a/src/Module/Directory/Domain/Repository/ContactRepositoryInterface.php b/src/Module/Directory/Domain/Repository/ContactRepositoryInterface.php new file mode 100644 index 0000000..0f28c4d --- /dev/null +++ b/src/Module/Directory/Domain/Repository/ContactRepositoryInterface.php @@ -0,0 +1,12 @@ + + */ +final class DoctrineContactRepository extends ServiceEntityRepository implements ContactRepositoryInterface +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Contact::class); + } + + public function findById(int $id): ?Contact + { + return $this->find($id); + } +}