src/Entity/Olympiad/Online/Participant.php line 29

  1. <?php
  2. namespace App\Entity\Olympiad\Online;
  3. use App\Entity\Common\BirthCertificate;
  4. use App\Entity\Common\Country;
  5. use App\Entity\Common\Passport;
  6. use App\Entity\Geo\Region;
  7. use App\Entity\Olympiad\Online\Embeded\AdditionalInfo;
  8. use App\Entity\Traits\CreatedTrait;
  9. use App\Entity\Traits\UpdatedTrait;
  10. use App\Entity\User\User;
  11. use App\Model\Olympiad\Online\AppliableInterface;
  12. use App\Validator\Constraints\Olympiad\ParticipantFull;
  13. use DateTime;
  14. use Doctrine\ORM\Mapping as ORM;
  15. use Doctrine\ORM\Mapping\UniqueConstraint;
  16. use Symfony\Component\Security\Core\User\UserInterface;
  17. use Symfony\Component\Validator\Constraints as Assert;
  18. //#[ORM\Entity(repositoryClass: "App\Repository\Olympiad\Online\ParticipantRepository")]
  19. //#[ORM\Table(name: "olymp_online_participant")]
  20. //#[UniqueConstraint(name: "pdc", columns: ["code", "direction_id"])]
  21. #[ParticipantFull]
  22. #[ORM\Table(name'olymp_online_participant')]
  23. #[UniqueConstraint(name'pdc'columns: ['code''direction_id'])]
  24. #[ORM\Entity(repositoryClass'App\Repository\Olympiad\Online\ParticipantRepository')]
  25. #[ORM\HasLifecycleCallbacks]
  26. class Participant implements AppliableInterface
  27. {
  28.     use CreatedTrait;
  29.     use UpdatedTrait;
  30.     public const STATE_NEW 'new';
  31.     public const STATE_SEND 'send';
  32.     public const STATE_ACCEPTED 'accepted';
  33.     public const STATE_DISMISSED 'dismissed';
  34.     public const TYPE_SCHOOL 1;
  35.     public const TYPE_STUDENT 2;
  36.     public const PUPIL_TYPE_BACHELOR 'bachelor';
  37.     public const PUPIL_TYPE_MASTER 'master';
  38.     public const PUPIL_TYPE_SPECIALIST 'specialist';
  39.     public const DOC_PASSPORT 'passport';
  40.     public const DOC_BIRTH_CERTIFICATE 'birth_certificate';
  41.     /**
  42.      * @var Direction
  43.      */
  44.     #[ORM\ManyToOne(targetEntity'App\Entity\Olympiad\Online\Direction'inversedBy'participants')]
  45.     #[ORM\JoinColumn(nullablefalse)]
  46.     private ?Direction $direction null;
  47.     /**
  48.      * @var Country|null
  49.      */
  50.     #[ORM\ManyToOne(targetEntity'App\Entity\Common\Country')]
  51.     #[ORM\JoinColumn(nullabletrue)]
  52.     #[Assert\NotBlank(groups: ['full_apply''Default'])]
  53.     private ?Country $country null;
  54.     /**
  55.      * @var string
  56.      */
  57.     #[ORM\Column(type'string'nullablefalseoptions: ['default' => 'new'])]
  58.     private string $state self::STATE_NEW;
  59.     #[ORM\Id]
  60.     #[ORM\GeneratedValue(strategy'AUTO')]
  61.     #[ORM\Column(type'integer')]
  62.     private ?int $id null;
  63.     #[ORM\Column(type'string'nullabletrue)]
  64.     private ?string $code null;
  65.     #[ORM\Column(type'string'length36)]
  66.     private string $uuid;
  67.     #[ORM\Column(type'boolean')]
  68.     private bool $confirmed false;
  69.     /**
  70.      * @var string
  71.      */
  72.     #[ORM\Column(type'string')]
  73.     #[Assert\NotBlank(groups: ['full_apply''Default'])]
  74.     private string $firstName;
  75.     /**
  76.      * @var string|null
  77.      *
  78.      */
  79.     #[ORM\Column(type'string'nullabletrue)]
  80.     private ?string $middleName null;
  81.     /**
  82.      * @var string
  83.      */
  84.     #[ORM\Column(type'string')]
  85.     #[Assert\NotBlank(groups: ['full_apply''Default'])]
  86.     private string $lastName;
  87.     /**
  88.      * @var ?DateTime
  89.      */
  90.     #[ORM\Column(type'date'nullabletrue)]
  91.     #[Assert\NotBlank(groups: ['full_apply'])]
  92.     #[Assert\GreaterThan('-45 years'groups: ['Default''full_apply'])]
  93.     #[Assert\LessThan('-10 years'groups: ['Default''full_apply'])]
  94.     private ?Datetime $birthday null;
  95.     /**
  96.      * @var string|null
  97.      */
  98.     #[ORM\Column(type'string'length50nullabletrue)]
  99.     #[Assert\NotBlank(groups: ['russian_apply''russian_passport'])]
  100.     private ?string $phone null;
  101.     /**
  102.      * @var string|null
  103.      */
  104.     #[ORM\Column(type'string'length50nullabletrue)]
  105.     #[Assert\NotBlank(groups: ['full_apply''Default'])]
  106.     #[Assert\Email(groups: ['full_apply''Default'], mode'strict')]
  107.     private ?string $email null;
  108.     #[ORM\ManyToOne(targetEntity'App\Entity\Geo\Region')]
  109.     #[Assert\NotBlank(groups: ['russian_apply''russian_passport'])]
  110.     private ?Region $region;
  111.     #[ORM\ManyToOne(targetEntity'App\Entity\User\User')]
  112.     private ?User $user null;
  113.     #[ORM\Column(type'string'nullabletrue)]
  114.     #[Assert\NotBlank(groups: ['full_apply'])]
  115.     private ?string $education;
  116.     #[ORM\Column(type'string'nullabletrue)]
  117.     #[Assert\NotBlank(groups: ['full_apply'])]
  118.     private ?string $class;
  119.     #[ORM\Column(type'string'nullabletrue)]
  120.     #[Assert\NotBlank(groups: ['full_apply_student'])]
  121.     private ?string $pupilLevel;
  122.     #[ORM\Column(type'string'nullabletrue)]
  123.     private ?string $eduOrganisationType;
  124.     #[ORM\Column(type'string'nullabletrue)]
  125.     #[Assert\NotBlank(groups: ['full_apply'])]
  126.     private ?string $eduOrganisation;
  127.     #[ORM\Embedded(class: 'App\Entity\Common\Passport'columnPrefix'p_')]
  128.     #[Assert\Valid(groups: ['russian_passport''russian_apply''full_apply_p''Default'])]
  129.     private Passport $passport;
  130.     #[ORM\Embedded(class: 'App\Entity\Common\BirthCertificate'columnPrefix'bc_')]
  131.     #[Assert\Valid(groups: ['full_apply_bc''Default'])]
  132.     private BirthCertificate $bc;
  133.     #[ORM\Column(type'boolean'options: ['default' => false])]
  134.     private bool $canceled false;
  135.     /**
  136.      * @var User|null
  137.      */
  138.     #[ORM\ManyToOne(targetEntity'App\Entity\User\User')]
  139.     private ?User $canceledBy null;
  140.     /**
  141.      * @var DateTime|null
  142.      */
  143.     #[ORM\Column(type'datetime'nullabletrue)]
  144.     private ?\DateTime $canceledAt null;
  145.     /**
  146.      * @var int|null
  147.      */
  148.     #[ORM\Column(type'integer'nullabletrue)]
  149.     private ?int $moodle_user_id null;
  150.     /**
  151.      * @var string|null
  152.      */
  153.     #[ORM\Column(type'string'nullabletrue)]
  154.     private ?string $moodle_user_login null;
  155.     /**
  156.      * @var string|null
  157.      */
  158.     #[ORM\Column(type'string'nullabletrue)]
  159.     private ?string $moodle_user_password null;
  160.     /**
  161.      * @var string|null
  162.      */
  163.     #[ORM\Column(type'text'nullabletrue)]
  164.     #[Assert\NotBlank(groups: ['full_apply''Default'])]
  165.     private ?string $addressRegistration null;
  166.     /**
  167.      * @var string|null
  168.      */
  169.     #[ORM\Column(type'text'nullabletrue)]
  170.     #[Assert\NotBlank(groups: ['full_apply''Default'])]
  171.     private ?string $addressFact null;
  172.     /**
  173.      * @var Country|null
  174.      */
  175.     #[ORM\ManyToOne(targetEntity'App\Entity\Common\Country')]
  176.     #[ORM\JoinColumn(nullabletrue)]
  177.     #[Assert\NotBlank(groups: ['full_apply''Default'])]
  178.     private ?Country $countryResidence null;
  179.     /**
  180.      * @var ?string
  181.      */
  182.     #[ORM\Column(type'string'nullabletrue)]
  183.     #[Assert\NotBlank(groups: ['full_apply''Default'])]
  184.     private ?string $cityResidence;
  185.     /**
  186.      * @var bool
  187.      */
  188.     #[ORM\Column(type'boolean'nullablefalsename'is_test_data'options: ['default' => 0])]
  189.     private bool $test_data false;
  190.     /**
  191.      * @var AdditionalInfo
  192.      */
  193.     #[ORM\Embedded(class: 'App\Entity\Olympiad\Online\Embeded\AdditionalInfo'columnPrefix'ai_')]
  194.     private AdditionalInfo $additionalInfo;
  195.     /**
  196.      * @var bool
  197.      */
  198.     #[ORM\Column(type'boolean'nullablefalsename'is_apply_allow'options: ['default' => 0])]
  199.     private bool $applyAllow false;
  200.     /**
  201.      * @var string
  202.      */
  203.     #[ORM\Column(type'string'nullabletrueoptions: ['default' => 'passport'])]
  204.     #[Assert\NotBlank(groups: ['full_apply''Default'])]
  205.     private string $docType self::DOC_PASSPORT;
  206.     #[ORM\ManyToOne(targetEntity'App\Entity\Olympiad\Online\Language')]
  207.     #[ORM\JoinColumn(nullabletruereferencedColumnName'locale'name'test_lang')]
  208.     private ?Language $test_lang null;
  209.     /**
  210.      * @var CourseOverride|null
  211.      */
  212.     #[ORM\ManyToOne(targetEntity'App\Entity\Olympiad\Online\CourseOverride'inversedBy'participants')]
  213.     #[ORM\JoinColumn(nullabletrue)]
  214.     private ?CourseOverride $courseOverride null;
  215.     public function __construct()
  216.     {
  217.         $this->passport = new Passport();
  218.         $this->bc = new BirthCertificate();
  219.         $this->additionalInfo = new AdditionalInfo();
  220.     }
  221.     /**
  222.      * @return int
  223.      */
  224.     public function getId(): ?int
  225.     {
  226.         return $this->id;
  227.     }
  228.     /**
  229.      * @param int $id
  230.      */
  231.     public function setId(int $id): void
  232.     {
  233.         $this->id $id;
  234.     }
  235.     /**
  236.      * @return string
  237.      */
  238.     public function getUuid(): string
  239.     {
  240.         return $this->uuid;
  241.     }
  242.     /**
  243.      * @param string $uuid
  244.      */
  245.     public function setUuid(string $uuid): void
  246.     {
  247.         $this->uuid $uuid;
  248.     }
  249.     /**
  250.      * @return bool
  251.      */
  252.     public function isConfirmed(): bool
  253.     {
  254.         return $this->confirmed;
  255.     }
  256.     /**
  257.      * @param bool $confirmed
  258.      */
  259.     public function setConfirmed(bool $confirmed): void
  260.     {
  261.         $this->confirmed $confirmed;
  262.     }
  263.     /**
  264.      * @return string
  265.      */
  266.     public function getFirstName(): string
  267.     {
  268.         return $this->firstName;
  269.     }
  270.     /**
  271.      * @param string $firstName
  272.      */
  273.     public function setFirstName(string $firstName): void
  274.     {
  275.         $this->firstName $firstName;
  276.     }
  277.     /**
  278.      * @return string|null
  279.      */
  280.     public function getMiddleName(): ?string
  281.     {
  282.         return $this->middleName;
  283.     }
  284.     /**
  285.      * @param string|null $middleName
  286.      */
  287.     public function setMiddleName(?string $middleName): void
  288.     {
  289.         $this->middleName $middleName;
  290.     }
  291.     /**
  292.      * @return string
  293.      */
  294.     public function getLastName(): string
  295.     {
  296.         return $this->lastName;
  297.     }
  298.     /**
  299.      * @param string $lastName
  300.      */
  301.     public function setLastName(string $lastName): void
  302.     {
  303.         $this->lastName $lastName;
  304.     }
  305.     /**
  306.      * @return DateTime
  307.      */
  308.     public function getBirthday(): ?Datetime
  309.     {
  310.         return $this->birthday;
  311.     }
  312.     /**
  313.      * @param DateTime|null $birthday
  314.      */
  315.     public function setBirthday(?Datetime $birthday): void
  316.     {
  317.         $this->birthday $birthday;
  318.     }
  319.     /**
  320.      * @return string|null
  321.      */
  322.     public function getPhone(): ?string
  323.     {
  324.         return $this->phone;
  325.     }
  326.     /**
  327.      * @param string|null $phone
  328.      */
  329.     public function setPhone(?string $phone): void
  330.     {
  331.         $this->phone $phone;
  332.     }
  333.     /**
  334.      * @return string|null
  335.      */
  336.     public function getEmail(): ?string
  337.     {
  338.         return $this->email;
  339.     }
  340.     /**
  341.      * @param string|null $email
  342.      */
  343.     public function setEmail(?string $email): void
  344.     {
  345.         $this->email $email;
  346.     }
  347.     /**
  348.      * @return Region|null
  349.      */
  350.     public function getRegion(): ?Region
  351.     {
  352.         return $this->region;
  353.     }
  354.     /**
  355.      * @param Region|null $region
  356.      */
  357.     public function setRegion(?Region $region): void
  358.     {
  359.         $this->region $region;
  360.     }
  361.     /**
  362.      * @return string|null
  363.      */
  364.     public function getEducation(): ?string
  365.     {
  366.         return $this->education;
  367.     }
  368.     /**
  369.      * @param string|null $education
  370.      */
  371.     public function setEducation(?string $education): void
  372.     {
  373.         $this->education $education;
  374.     }
  375.     /**
  376.      * @return string|null
  377.      */
  378.     public function getClass(): ?string
  379.     {
  380.         return $this->class;
  381.     }
  382.     /**
  383.      * @param string|null $class
  384.      */
  385.     public function setClass(?string $class): void
  386.     {
  387.         $this->class $class;
  388.     }
  389.     /**
  390.      * @return string|null
  391.      */
  392.     public function getEduOrganisationType(): ?string
  393.     {
  394.         return $this->eduOrganisationType;
  395.     }
  396.     /**
  397.      * @param string|null $eduOrganisationType
  398.      */
  399.     public function setEduOrganisationType(?string $eduOrganisationType): void
  400.     {
  401.         $this->eduOrganisationType $eduOrganisationType;
  402.     }
  403.     /**
  404.      * @return string|null
  405.      */
  406.     public function getEduOrganisation(): ?string
  407.     {
  408.         return $this->eduOrganisation;
  409.     }
  410.     /**
  411.      * @param string|null $eduOrganisation
  412.      */
  413.     public function setEduOrganisation(?string $eduOrganisation): void
  414.     {
  415.         $this->eduOrganisation $eduOrganisation;
  416.     }
  417.     /**
  418.      * @return Passport
  419.      */
  420.     public function getPassport(): Passport
  421.     {
  422.         return $this->passport;
  423.     }
  424.     /**
  425.      * @param Passport $passport
  426.      */
  427.     public function setPassport(Passport $passport): void
  428.     {
  429.         $this->passport $passport;
  430.     }
  431.     /**
  432.      * @return Direction
  433.      */
  434.     public function getDirection(): ?Direction
  435.     {
  436.         return $this->direction;
  437.     }
  438.     /**
  439.      * @param Direction $direction
  440.      */
  441.     public function setDirection(Direction $direction): void
  442.     {
  443.         $this->direction $direction;
  444.     }
  445.     /**
  446.      * @return User
  447.      */
  448.     public function getUser(): ?User
  449.     {
  450.         return $this->user;
  451.     }
  452.     /**
  453.      * @param User $user
  454.      */
  455.     public function setUser(User $user): void
  456.     {
  457.         $this->user $user;
  458.     }
  459.     /**
  460.      * @return bool
  461.      */
  462.     public function isCanceled(): bool
  463.     {
  464.         return $this->canceled;
  465.     }
  466.     /**
  467.      * @param bool $canceled
  468.      */
  469.     public function setCanceled(bool $canceled): void
  470.     {
  471.         $this->canceled $canceled;
  472.     }
  473.     /**
  474.      * @return User|null
  475.      */
  476.     public function getCanceledBy(): ?User
  477.     {
  478.         return $this->canceledBy;
  479.     }
  480.     /**
  481.      * @param User|null|UserInterface $canceledBy
  482.      */
  483.     public function setCanceledBy(?User $canceledBy): void
  484.     {
  485.         $this->canceledBy $canceledBy;
  486.     }
  487.     /**
  488.      * @return DateTime|null
  489.      */
  490.     public function getCanceledAt(): ?DateTime
  491.     {
  492.         return $this->canceledAt;
  493.     }
  494.     /**
  495.      * @param DateTime|null $canceledAt
  496.      */
  497.     public function setCanceledAt(?DateTime $canceledAt): void
  498.     {
  499.         $this->canceledAt $canceledAt;
  500.     }
  501.     /**
  502.      * @return Country|null
  503.      */
  504.     public function getCountry(): ?Country
  505.     {
  506.         return $this->country;
  507.     }
  508.     /**
  509.      * @param Country|null $country
  510.      */
  511.     public function setCountry(?Country $country): void
  512.     {
  513.         $this->country $country;
  514.     }
  515.     /**
  516.      * @return string
  517.      */
  518.     public function getState(): string
  519.     {
  520.         return $this->state;
  521.     }
  522.     /**
  523.      * @param string $state
  524.      */
  525.     public function setState(string $state): void
  526.     {
  527.         $this->state $state;
  528.     }
  529.     /**
  530.      * @return int|null
  531.      */
  532.     public function getMoodleUserId(): ?int
  533.     {
  534.         return $this->moodle_user_id;
  535.     }
  536.     /**
  537.      * @param int|null $moodle_user_id
  538.      */
  539.     public function setMoodleUserId(?int $moodle_user_id): void
  540.     {
  541.         $this->moodle_user_id $moodle_user_id;
  542.     }
  543.     /**
  544.      * @return string|null
  545.      */
  546.     public function getMoodleUserLogin(): ?string
  547.     {
  548.         return $this->moodle_user_login;
  549.     }
  550.     /**
  551.      * @param string|null $moodle_user_login
  552.      */
  553.     public function setMoodleUserLogin(?string $moodle_user_login): void
  554.     {
  555.         $this->moodle_user_login $moodle_user_login;
  556.     }
  557.     /**
  558.      * @return string|null
  559.      */
  560.     public function getMoodleUserPassword(): ?string
  561.     {
  562.         return $this->moodle_user_password;
  563.     }
  564.     /**
  565.      * @param string|null $moodle_user_password
  566.      */
  567.     public function setMoodleUserPassword(?string $moodle_user_password): void
  568.     {
  569.         $this->moodle_user_password $moodle_user_password;
  570.     }
  571.     public function getFullname(): string
  572.     {
  573.         return trim(str_replace('  '' 'sprintf('%s %s %s'$this->lastName$this->firstName$this->middleName)));
  574.     }
  575.     /**
  576.      * @return string|null
  577.      */
  578.     public function getAddressRegistration(): ?string
  579.     {
  580.         return $this->addressRegistration;
  581.     }
  582.     /**
  583.      * @param string|null $addressRegistration
  584.      */
  585.     public function setAddressRegistration(?string $addressRegistration): void
  586.     {
  587.         $this->addressRegistration $addressRegistration;
  588.     }
  589.     /**
  590.      * @return string|null
  591.      */
  592.     public function getAddressFact(): ?string
  593.     {
  594.         return $this->addressFact;
  595.     }
  596.     /**
  597.      * @param string|null $addressFact
  598.      */
  599.     public function setAddressFact(?string $addressFact): void
  600.     {
  601.         $this->addressFact $addressFact;
  602.     }
  603.     /**
  604.      * @return AdditionalInfo
  605.      */
  606.     public function getAdditionalInfo(): AdditionalInfo
  607.     {
  608.         return $this->additionalInfo;
  609.     }
  610.     /**
  611.      * @param AdditionalInfo $additionalInfo
  612.      */
  613.     public function setAdditionalInfo(AdditionalInfo $additionalInfo): void
  614.     {
  615.         $this->additionalInfo $additionalInfo;
  616.     }
  617.     /**
  618.      * @return bool
  619.      */
  620.     public function isApplyAllow(): bool
  621.     {
  622.         return $this->applyAllow;
  623.     }
  624.     /**
  625.      * @param bool $applyAllow
  626.      */
  627.     public function setApplyAllow(bool $applyAllow): void
  628.     {
  629.         $this->applyAllow $applyAllow;
  630.     }
  631.     /**
  632.      * @return string|null
  633.      */
  634.     public function getCode(): ?string
  635.     {
  636.         return $this->code;
  637.     }
  638.     /**
  639.      * @param string|null $code
  640.      */
  641.     public function setCode(?string $code): void
  642.     {
  643.         $this->code $code;
  644.     }
  645.     /**
  646.      * @return string|null
  647.      */
  648.     public function getPupilLevel(): ?string
  649.     {
  650.         return $this->pupilLevel;
  651.     }
  652.     /**
  653.      * @param string|null $pupilLevel
  654.      */
  655.     public function setPupilLevel(?string $pupilLevel): void
  656.     {
  657.         $this->pupilLevel $pupilLevel;
  658.     }
  659.     /**
  660.      * @return Country|null
  661.      */
  662.     public function getCountryResidence(): ?Country
  663.     {
  664.         return $this->countryResidence;
  665.     }
  666.     /**
  667.      * @param Country|null $countryResidence
  668.      */
  669.     public function setCountryResidence(?Country $countryResidence): void
  670.     {
  671.         $this->countryResidence $countryResidence;
  672.     }
  673.     /**
  674.      * @return string|null
  675.      */
  676.     public function getCityResidence(): ?string
  677.     {
  678.         return $this->cityResidence;
  679.     }
  680.     /**
  681.      * @param string|null $cityResidence
  682.      */
  683.     public function setCityResidence(?string $cityResidence): void
  684.     {
  685.         $this->cityResidence $cityResidence;
  686.     }
  687.     /**
  688.      * @return BirthCertificate
  689.      */
  690.     public function getBc(): BirthCertificate
  691.     {
  692.         return $this->bc;
  693.     }
  694.     /**
  695.      * @param BirthCertificate $bc
  696.      */
  697.     public function setBc(BirthCertificate $bc): void
  698.     {
  699.         $this->bc $bc;
  700.     }
  701.     /**
  702.      * @return string
  703.      */
  704.     public function getDocType(): string
  705.     {
  706.         return $this->docType;
  707.     }
  708.     /**
  709.      * @param string $docType
  710.      */
  711.     public function setDocType(string $docType): void
  712.     {
  713.         $this->docType $docType;
  714.     }
  715.     /**
  716.      * @return Language|null
  717.      */
  718.     public function getTestLang(): ?Language
  719.     {
  720.         return $this->test_lang;
  721.     }
  722.     /**
  723.      * @param Language|null $test_lang
  724.      */
  725.     public function setTestLang(?Language $test_lang): void
  726.     {
  727.         $this->test_lang $test_lang;
  728.     }
  729.     /**
  730.      * @return CourseOverride|null
  731.      */
  732.     public function getCourseOverride(): ?CourseOverride
  733.     {
  734.         return $this->courseOverride;
  735.     }
  736.     /**
  737.      * @param CourseOverride|null $courseOverride
  738.      */
  739.     public function setCourseOverride(?CourseOverride $courseOverride): void
  740.     {
  741.         $this->courseOverride $courseOverride;
  742.     }
  743. }