src/JanusHercules/JoboffererRegistration/Domain/Entity/PaymentFormDatabag.php line 25

Open in your IDE?
  1. <?php
  2. namespace JanusHercules\JoboffererRegistration\Domain\Entity;
  3. use App\Entity\User;
  4. use App\Utility\DatabaseIdGenerator;
  5. use App\Validator\Constraint as AppAssert;
  6. use DateTime;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping\Column;
  9. use Doctrine\ORM\Mapping\CustomIdGenerator;
  10. use Doctrine\ORM\Mapping\Entity;
  11. use Doctrine\ORM\Mapping\GeneratedValue;
  12. use Doctrine\ORM\Mapping\Id;
  13. use Doctrine\ORM\Mapping\JoinColumn;
  14. use Doctrine\ORM\Mapping\OneToOne;
  15. use Doctrine\ORM\Mapping\Table;
  16. use InvalidArgumentException;
  17. use Symfony\Component\Validator\Constraints as Assert;
  18. #[Entity]
  19. #[Table(
  20. name: 'payment_form_databags',
  21. )]
  22. class PaymentFormDatabag
  23. {
  24. public function __construct(
  25. User $user,
  26. ) {
  27. $this->userId = $user;
  28. $this->createdAt = new DateTime();
  29. }
  30. #[Id]
  31. #[GeneratedValue(strategy: 'CUSTOM')]
  32. #[CustomIdGenerator(class: DatabaseIdGenerator::class)]
  33. #[Column(
  34. type : Types::GUID,
  35. unique: true
  36. )]
  37. private string $id;
  38. public function getId(): string
  39. {
  40. return $this->id;
  41. }
  42. public function setId(string $id): void
  43. {
  44. $this->id = $id;
  45. }
  46. #[Column(
  47. type : Types::DATETIME_MUTABLE,
  48. nullable: false
  49. )]
  50. private DateTime $createdAt;
  51. public function getCreatedAt(): DateTime
  52. {
  53. return $this->createdAt;
  54. }
  55. public function setCreatedAt(DateTime $createdAt): void
  56. {
  57. $this->createdAt = $createdAt;
  58. }
  59. #[Column(
  60. type : Types::DATETIME_MUTABLE,
  61. nullable: false
  62. )]
  63. private DateTime $updatedAt;
  64. public function getUpdatedAt(): DateTime
  65. {
  66. return $this->updatedAt;
  67. }
  68. public function setUpdatedAt(DateTime $updatedAt): void
  69. {
  70. $this->updatedAt = $updatedAt;
  71. }
  72. #[OneToOne(
  73. targetEntity: User::class,
  74. )]
  75. #[JoinColumn(
  76. name: 'users_id',
  77. referencedColumnName: 'id',
  78. nullable: false,
  79. onDelete: 'CASCADE'
  80. )]
  81. public User $userId;
  82. public function getUserId(): User
  83. {
  84. return $this->userId;
  85. }
  86. public function setUserId(User $user): void
  87. {
  88. $this->userId = $user;
  89. }
  90. #[Column(
  91. name: 'email_for_invoice',
  92. type: Types::STRING,
  93. length: 128,
  94. nullable: true
  95. )]
  96. #[Assert\Email]
  97. private ?string $emailForInvoice;
  98. public function getEmailForInvoice(): ?string
  99. {
  100. return $this->emailForInvoice;
  101. }
  102. public function setEmailForInvoice(?string $emailForInvoice = null): void
  103. {
  104. $this->emailForInvoice = $emailForInvoice;
  105. }
  106. // form field names in form differ from database
  107. public function setEmailAddress(?string $emailForInvoice = null): void
  108. {
  109. $this->emailForInvoice = $emailForInvoice;
  110. }
  111. #[Column(
  112. name: 'firstname',
  113. type: Types::STRING,
  114. length: 128,
  115. nullable: true
  116. )]
  117. #[Assert\Length(min: 0, max: 50)]
  118. private ?string $firstname;
  119. public function getFirstname(): ?string
  120. {
  121. return $this->firstname;
  122. }
  123. public function setFirstname(?string $firstname = null): void
  124. {
  125. $this->firstname = $firstname;
  126. }
  127. #[Column(
  128. name: 'lastname',
  129. type: Types::STRING,
  130. length: 128,
  131. nullable: true
  132. )]
  133. #[Assert\Length(min: 0, max: 50)]
  134. private ?string $lastname;
  135. public function getLastname(): ?string
  136. {
  137. return $this->lastname;
  138. }
  139. public function setLastname(?string $lastname = null): void
  140. {
  141. $this->lastname = $lastname;
  142. }
  143. #[Column(
  144. name: 'streetname',
  145. type: Types::STRING,
  146. length: 128,
  147. nullable: true)]
  148. #[Assert\Length(
  149. min: 5,
  150. max: 128,
  151. )]
  152. private ?string $streetname;
  153. public function getStreetname(): ?string
  154. {
  155. return $this->streetname;
  156. }
  157. public function setStreetname(?string $streetname = null): void
  158. {
  159. $this->streetname = $streetname;
  160. }
  161. // form field names in form differ from database
  162. public function setAddressStreet(?string $streetname = null): void
  163. {
  164. $this->streetname = $streetname;
  165. }
  166. #[Column(
  167. name: 'house_number',
  168. type: Types::STRING,
  169. length: 128,
  170. nullable: true)]
  171. #[Assert\Length(
  172. min: 1,
  173. max: 128,
  174. )]
  175. private ?string $houseNumber;
  176. public function getHouseNumber(): ?string
  177. {
  178. return $this->houseNumber;
  179. }
  180. public function setHouseNumber(?string $houseNumber = null): void
  181. {
  182. $this->houseNumber = $houseNumber;
  183. }
  184. // form field names in form differ from database
  185. public function setAddressHouseNumber(?string $houseNumber = null): void
  186. {
  187. $this->houseNumber = $houseNumber;
  188. }
  189. public function getStreetAndHouseNumber(): string
  190. {
  191. return $this->streetname . ' ' . $this->houseNumber;
  192. }
  193. #[Column(
  194. name: 'zipcode',
  195. type: Types::STRING,
  196. length: 128,
  197. nullable: true
  198. )]
  199. #[Assert\Type('string')]
  200. #[AppAssert\KnownZipcode(
  201. message : 'Diese PLZ ist uns leider nicht bekannt.',
  202. zipcodeIsAtStartOfString: true,
  203. groups : ['step1']
  204. )]
  205. private ?string $zipcode = null;
  206. public function getZipcode(): ?string
  207. {
  208. return $this->zipcode;
  209. }
  210. public function setZipcode(?string $zipcode = null): void
  211. {
  212. if (!is_null($zipcode)) {
  213. $trimmedZipcode = trim($zipcode);
  214. if (mb_strlen($trimmedZipcode) !== 5 || !is_numeric($trimmedZipcode)) {
  215. throw new InvalidArgumentException("zipcode must either be null or a string with 5 digits, but got '$zipcode'");
  216. }
  217. $zipcode = $trimmedZipcode;
  218. }
  219. $this->zipcode = $zipcode;
  220. }
  221. // form field names in form differ from database
  222. public function setAddressPostalCode(?string $zipcode = null): void
  223. {
  224. if (!is_null($zipcode)) {
  225. $trimmedZipcode = trim($zipcode);
  226. if (mb_strlen($trimmedZipcode) !== 5 || !is_numeric($trimmedZipcode)) {
  227. throw new InvalidArgumentException("zipcode must either be null or a string with 5 digits, but got '$zipcode'");
  228. }
  229. $zipcode = $trimmedZipcode;
  230. }
  231. $this->zipcode = $zipcode;
  232. }
  233. #[Column(
  234. name: 'city',
  235. type: Types::STRING,
  236. length: 128,
  237. nullable: true
  238. )]
  239. #[Assert\Length(
  240. min: 2,
  241. max: 128,
  242. )]
  243. private ?string $city;
  244. public function getCity(): ?string
  245. {
  246. return $this->city;
  247. }
  248. public function setCity(?string $city = null): void
  249. {
  250. if (!is_null($city)) {
  251. $this->city = mb_substr($city, 0, 128);
  252. }
  253. }
  254. // form field names in form differ from database
  255. public function setAddressCity(?string $city = null): void
  256. {
  257. if (!is_null($city)) {
  258. $this->city = mb_substr($city, 0, 128);
  259. }
  260. }
  261. #[Column(
  262. name: 'businessName',
  263. type: Types::STRING,
  264. length: 128,
  265. nullable: true
  266. )]
  267. #[Assert\Length(
  268. min: 2,
  269. max: 100,
  270. )]
  271. private ?string $businessName;
  272. public function getBusinessName(): ?string
  273. {
  274. return $this->businessName;
  275. }
  276. public function setBusinessName(?string $businessName = null): void
  277. {
  278. if (!is_null($businessName)) {
  279. $this->businessName = mb_substr($businessName, 0, 128);
  280. } else {
  281. $this->businessName = null;
  282. }
  283. }
  284. // form field names in form differ from database
  285. public function setCompanyName(?string $businessName = null): void
  286. {
  287. if (!is_null($businessName)) {
  288. $this->businessName = mb_substr($businessName, 0, 128);
  289. } else {
  290. $this->businessName = null;
  291. }
  292. }
  293. #[Column(
  294. name: 'mobilenumber',
  295. type: Types::STRING,
  296. length: 128,
  297. nullable: true
  298. )]
  299. #[Assert\Length(
  300. min: 6,
  301. max: 30,
  302. )]
  303. #[Assert\Regex(pattern: "/^[ +\-\/0-9]{6,30}$/")]
  304. private ?string $mobilenumber;
  305. public function getMobilenumber(): ?string
  306. {
  307. return $this->mobilenumber;
  308. }
  309. public function setMobilenumber(?string $mobilenumber = null): void
  310. {
  311. $this->mobilenumber = $mobilenumber;
  312. }
  313. // form field names in form differ from database
  314. public function setPhoneNumber(?string $mobilenumber = null): void
  315. {
  316. $this->mobilenumber = $mobilenumber;
  317. }
  318. }