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