<?php
namespace JanusHercules\CampaignWunschjobs\Presentation\Entity;
use App\Entity\Profile\JobseekerProfile;
use App\Utility\DatabaseIdGenerator;
use App\Utility\DateTimeUtility;
use App\Validator\Constraint as AppAssert;
use App\Value\ZipcodeRadiusesValue;
use DateTime;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Exception;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity]
#[ORM\Table(name: 'campaign_wunschjobs_jobseeker_flow_form_databags')]
class JobseekerFlowFormDatabag
{
/**
* @throws Exception
*/
public function __construct()
{
$this->createdAt = DateTimeUtility::createDateTimeUtc();
}
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: DatabaseIdGenerator::class)]
#[ORM\Column(
type: Types::GUID,
unique: true
)]
private ?string $id = null;
public function getId(): ?string
{
return $this->id;
}
#[ORM\Column(
type: Types::DATETIME_MUTABLE,
nullable: false
)]
private DateTime $createdAt;
public function setcreatedAt(DateTime $createdAt): void
{
$this->createdAt = $createdAt;
}
public function getcreatedAt(): DateTime
{
return $this->createdAt;
}
#[Assert\NotBlank(
message: 'Bitte gib eine Berufsbezeichnung ein.',
groups: ['step1'])
]
#[AppAssert\LatinWord(groups: ['step1'])]
#[ORM\Column(
type: Types::STRING,
length: 1024,
nullable: false
)]
private ?string $what = null;
public function getWhat(): ?string
{
return $this->what;
}
public function setWhat(
string $what
): void {
$this->what = $what;
}
#[Assert\NotBlank(
message: 'Bitte gib eine Postleitzahl ein.',
groups: ['step1'])
]
#[AppAssert\KnownZipcode(
message : 'Diese PLZ ist uns leider nicht bekannt.',
zipcodeIsAtStartOfString: true,
groups : ['step1']
)]
#[ORM\Column(
type: Types::STRING,
length: 1024,
nullable: false
)]
private ?string $location = null;
public function getLocation(): ?string
{
return $this->location;
}
public function setLocation(
string $location
): void {
$this->location = $location;
}
public function getLocationZipcode(): ?string
{
if (is_null($this->location)) {
return null;
}
return mb_substr($this->location, 0, 5);
}
#[Assert\Choice(
choices: ZipcodeRadiusesValue::ALL,
groups: ['step1']
)]
#[ORM\Column(
type: Types::SMALLINT,
nullable: false
)]
private int $circumcircle = ZipcodeRadiusesValue::DEFAULT;
public function getCircumcircle(): int
{
return $this->circumcircle;
}
public function setCircumcircle(
int $circumcircle
): void {
$this->circumcircle = $circumcircle;
}
#[Assert\NotBlank(
message: 'Bitte gib einen Vornamen ein',
groups: ['step2']
)]
#[AppAssert\LatinWord(groups: ['step2'])]
#[ORM\Column(
type: Types::STRING,
length: 1024,
nullable: true
)]
private ?string $firstname = null;
public function getFirstname(): ?string
{
return $this->firstname;
}
public function setFirstname(
string $firstname
): void {
$this->firstname = $firstname;
}
#[Assert\NotBlank(
message: 'Bitte gib einen Nachnamen ein',
groups: ['step2']
)]
#[AppAssert\LatinWord(groups: ['step2'])]
#[ORM\Column(
type: Types::STRING,
length: 1024,
nullable: true
)]
private ?string $lastname = null;
public function getLastname(): ?string
{
return $this->lastname;
}
public function setLastname(
string $lastname
): void {
$this->lastname = $lastname;
}
#[Assert\NotBlank(
message: 'Bitte gib eine E-Mail Adresse ein',
groups: ['step2']
)]
#[AppAssert\Email(groups: ['step2'])]
#[ORM\Column(
type: Types::STRING,
length: 1024,
nullable: true
)]
private ?string $email = null;
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(
string $email
): void {
$this->email = $email;
}
#[Assert\NotBlank(
message: 'Mit einer Telefonnummer können Arbeitgeber dich schneller kontaktieren.',
groups : ['step2']
)]
#[Assert\Regex(
pattern: "/^[ +\-\/0-9]{6,30}$/",
message: 'Bitte geben Sie eine gültige Telefonnummer ein.',
groups : ['step2']
)]
#[ORM\Column(
type: Types::STRING,
length: 1024,
nullable: true
)]
private ?string $phone = null;
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(
string $phone
): void {
$this->phone = $phone;
}
#[ORM\ManyToOne(
targetEntity: JobseekerProfile::class,
cascade: ['persist']
)]
#[ORM\JoinColumn(
name: 'jobseeker_profiles_id',
referencedColumnName: 'id',
nullable: true,
onDelete: 'SET NULL'
)]
private ?JobseekerProfile $jobseekerProfile;
public function setJobseekerProfile(?JobseekerProfile $jobseekerProfile): void
{
$this->jobseekerProfile = $jobseekerProfile;
}
public function getJobseekerProfile(): ?JobseekerProfile
{
return $this->jobseekerProfile;
}
}