save data
This commit is contained in:
parent
baf91af971
commit
cb297074d2
@ -2,7 +2,7 @@ import { Controller } from "@hotwired/stimulus";
|
|||||||
import {loadStripe} from "@stripe/stripe-js";
|
import {loadStripe} from "@stripe/stripe-js";
|
||||||
|
|
||||||
export default class extends Controller {
|
export default class extends Controller {
|
||||||
static targets = ['key', 'submit'];
|
static targets = ['key', 'submit', 'firstname', 'lastname', 'email', 'phone'];
|
||||||
|
|
||||||
stripe;
|
stripe;
|
||||||
|
|
||||||
@ -40,7 +40,13 @@ export default class extends Controller {
|
|||||||
this.submitTarget.querySelector('svg').classList.remove('hidden');
|
this.submitTarget.querySelector('svg').classList.remove('hidden');
|
||||||
|
|
||||||
const forms = document.querySelectorAll("form");
|
const forms = document.querySelectorAll("form");
|
||||||
const formData = this.getFormData(forms);
|
const personalData = this.getPersonalData();
|
||||||
|
const ticketData = this.getTicketData(forms);
|
||||||
|
|
||||||
|
const formData = {
|
||||||
|
personal: personalData,
|
||||||
|
tickets: ticketData,
|
||||||
|
}
|
||||||
|
|
||||||
fetch("/ticket/submit", {
|
fetch("/ticket/submit", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@ -61,12 +67,29 @@ export default class extends Controller {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getFormData(forms) {
|
getTicketData(forms) {
|
||||||
const formData = [];
|
const formData = [];
|
||||||
forms.forEach((form) => {
|
forms.forEach((form) => {
|
||||||
formData.push(Object.fromEntries(new FormData(form).entries()));
|
formData.push(this.extractFormData(form));
|
||||||
});
|
});
|
||||||
|
|
||||||
return formData;
|
return formData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getPersonalData() {
|
||||||
|
return {
|
||||||
|
firstname: this.firstnameTarget.value,
|
||||||
|
lastname: this.lastnameTarget.value,
|
||||||
|
email: this.emailTarget.value,
|
||||||
|
phone: this.phoneTarget.value,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
extractFormData(form) {
|
||||||
|
return {
|
||||||
|
ticket: parseInt(form.querySelector('select[name="ticket"]').value),
|
||||||
|
food: parseInt(form.querySelector('select[name="food"]').value),
|
||||||
|
note: form.querySelector('input[name="note"]').value,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
@tailwind base;
|
@tailwind base;
|
||||||
@tailwind components;
|
@tailwind components;
|
||||||
@tailwind utilities;
|
@tailwind utilities;
|
||||||
|
|
||||||
|
.text-input {
|
||||||
|
@apply border border-gray-300 rounded-lg focus:ring-2 focus:ring-orange-500 outline-orange-500 focus:border-orange-500 transition-colors;
|
||||||
|
}
|
@ -7,11 +7,13 @@
|
|||||||
"php": ">=8.2",
|
"php": ">=8.2",
|
||||||
"ext-ctype": "*",
|
"ext-ctype": "*",
|
||||||
"ext-iconv": "*",
|
"ext-iconv": "*",
|
||||||
|
"doctrine/annotations": "^2.0",
|
||||||
"doctrine/dbal": "^3",
|
"doctrine/dbal": "^3",
|
||||||
"doctrine/doctrine-bundle": "^2.13",
|
"doctrine/doctrine-bundle": "^2.13",
|
||||||
"doctrine/doctrine-migrations-bundle": "^3.4",
|
"doctrine/doctrine-migrations-bundle": "^3.4",
|
||||||
"doctrine/orm": "^3.3",
|
"doctrine/orm": "^3.3",
|
||||||
"php-flasher/flasher-noty-symfony": "^2.1",
|
"php-flasher/flasher-noty-symfony": "^2.1",
|
||||||
|
"phpdocumentor/reflection-docblock": "^5.6",
|
||||||
"stripe/stripe-php": "^16.4",
|
"stripe/stripe-php": "^16.4",
|
||||||
"symfony/asset": "7.2.*",
|
"symfony/asset": "7.2.*",
|
||||||
"symfony/asset-mapper": "7.2.*",
|
"symfony/asset-mapper": "7.2.*",
|
||||||
@ -21,6 +23,8 @@
|
|||||||
"symfony/form": "7.2.*",
|
"symfony/form": "7.2.*",
|
||||||
"symfony/framework-bundle": "7.2.*",
|
"symfony/framework-bundle": "7.2.*",
|
||||||
"symfony/mailer": "7.2.*",
|
"symfony/mailer": "7.2.*",
|
||||||
|
"symfony/property-access": "7.2.*",
|
||||||
|
"symfony/property-info": "7.2.*",
|
||||||
"symfony/runtime": "7.2.*",
|
"symfony/runtime": "7.2.*",
|
||||||
"symfony/serializer": "7.2.*",
|
"symfony/serializer": "7.2.*",
|
||||||
"symfony/twig-bundle": "7.2.*",
|
"symfony/twig-bundle": "7.2.*",
|
||||||
|
386
composer.lock
generated
386
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "51f020bf0346145a2eaa666b7a83d36b",
|
"content-hash": "8dc2a9d9e624cf61b3c68d2678e9d53c",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "composer/semver",
|
"name": "composer/semver",
|
||||||
@ -87,6 +87,82 @@
|
|||||||
],
|
],
|
||||||
"time": "2024-09-19T14:15:21+00:00"
|
"time": "2024-09-19T14:15:21+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "doctrine/annotations",
|
||||||
|
"version": "2.0.2",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/doctrine/annotations.git",
|
||||||
|
"reference": "901c2ee5d26eb64ff43c47976e114bf00843acf7"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/doctrine/annotations/zipball/901c2ee5d26eb64ff43c47976e114bf00843acf7",
|
||||||
|
"reference": "901c2ee5d26eb64ff43c47976e114bf00843acf7",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"doctrine/lexer": "^2 || ^3",
|
||||||
|
"ext-tokenizer": "*",
|
||||||
|
"php": "^7.2 || ^8.0",
|
||||||
|
"psr/cache": "^1 || ^2 || ^3"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"doctrine/cache": "^2.0",
|
||||||
|
"doctrine/coding-standard": "^10",
|
||||||
|
"phpstan/phpstan": "^1.10.28",
|
||||||
|
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
|
||||||
|
"symfony/cache": "^5.4 || ^6.4 || ^7",
|
||||||
|
"vimeo/psalm": "^4.30 || ^5.14"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"php": "PHP 8.0 or higher comes with attributes, a native replacement for annotations"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Guilherme Blanco",
|
||||||
|
"email": "guilhermeblanco@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Roman Borschel",
|
||||||
|
"email": "roman@code-factory.org"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Benjamin Eberlei",
|
||||||
|
"email": "kontakt@beberlei.de"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Jonathan Wage",
|
||||||
|
"email": "jonwage@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Johannes Schmitt",
|
||||||
|
"email": "schmittjoh@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Docblock Annotations Parser",
|
||||||
|
"homepage": "https://www.doctrine-project.org/projects/annotations.html",
|
||||||
|
"keywords": [
|
||||||
|
"annotations",
|
||||||
|
"docblock",
|
||||||
|
"parser"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/doctrine/annotations/issues",
|
||||||
|
"source": "https://github.com/doctrine/annotations/tree/2.0.2"
|
||||||
|
},
|
||||||
|
"time": "2024-09-05T10:17:24+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "doctrine/cache",
|
"name": "doctrine/cache",
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
@ -1645,6 +1721,228 @@
|
|||||||
],
|
],
|
||||||
"time": "2025-01-18T10:26:31+00:00"
|
"time": "2025-01-18T10:26:31+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "phpdocumentor/reflection-common",
|
||||||
|
"version": "2.2.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/phpDocumentor/ReflectionCommon.git",
|
||||||
|
"reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b",
|
||||||
|
"reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^7.2 || ^8.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-2.x": "2.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"phpDocumentor\\Reflection\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Jaap van Otterdijk",
|
||||||
|
"email": "opensource@ijaap.nl"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Common reflection classes used by phpdocumentor to reflect the code structure",
|
||||||
|
"homepage": "http://www.phpdoc.org",
|
||||||
|
"keywords": [
|
||||||
|
"FQSEN",
|
||||||
|
"phpDocumentor",
|
||||||
|
"phpdoc",
|
||||||
|
"reflection",
|
||||||
|
"static analysis"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/phpDocumentor/ReflectionCommon/issues",
|
||||||
|
"source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x"
|
||||||
|
},
|
||||||
|
"time": "2020-06-27T09:03:43+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "phpdocumentor/reflection-docblock",
|
||||||
|
"version": "5.6.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
|
||||||
|
"reference": "e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8",
|
||||||
|
"reference": "e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"doctrine/deprecations": "^1.1",
|
||||||
|
"ext-filter": "*",
|
||||||
|
"php": "^7.4 || ^8.0",
|
||||||
|
"phpdocumentor/reflection-common": "^2.2",
|
||||||
|
"phpdocumentor/type-resolver": "^1.7",
|
||||||
|
"phpstan/phpdoc-parser": "^1.7|^2.0",
|
||||||
|
"webmozart/assert": "^1.9.1"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"mockery/mockery": "~1.3.5 || ~1.6.0",
|
||||||
|
"phpstan/extension-installer": "^1.1",
|
||||||
|
"phpstan/phpstan": "^1.8",
|
||||||
|
"phpstan/phpstan-mockery": "^1.1",
|
||||||
|
"phpstan/phpstan-webmozart-assert": "^1.2",
|
||||||
|
"phpunit/phpunit": "^9.5",
|
||||||
|
"psalm/phar": "^5.26"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "5.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"phpDocumentor\\Reflection\\": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Mike van Riel",
|
||||||
|
"email": "me@mikevanriel.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Jaap van Otterdijk",
|
||||||
|
"email": "opensource@ijaap.nl"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues",
|
||||||
|
"source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.6.1"
|
||||||
|
},
|
||||||
|
"time": "2024-12-07T09:39:29+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "phpdocumentor/type-resolver",
|
||||||
|
"version": "1.10.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/phpDocumentor/TypeResolver.git",
|
||||||
|
"reference": "679e3ce485b99e84c775d28e2e96fade9a7fb50a"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/679e3ce485b99e84c775d28e2e96fade9a7fb50a",
|
||||||
|
"reference": "679e3ce485b99e84c775d28e2e96fade9a7fb50a",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"doctrine/deprecations": "^1.0",
|
||||||
|
"php": "^7.3 || ^8.0",
|
||||||
|
"phpdocumentor/reflection-common": "^2.0",
|
||||||
|
"phpstan/phpdoc-parser": "^1.18|^2.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"ext-tokenizer": "*",
|
||||||
|
"phpbench/phpbench": "^1.2",
|
||||||
|
"phpstan/extension-installer": "^1.1",
|
||||||
|
"phpstan/phpstan": "^1.8",
|
||||||
|
"phpstan/phpstan-phpunit": "^1.1",
|
||||||
|
"phpunit/phpunit": "^9.5",
|
||||||
|
"rector/rector": "^0.13.9",
|
||||||
|
"vimeo/psalm": "^4.25"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-1.x": "1.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"phpDocumentor\\Reflection\\": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Mike van Riel",
|
||||||
|
"email": "me@mikevanriel.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/phpDocumentor/TypeResolver/issues",
|
||||||
|
"source": "https://github.com/phpDocumentor/TypeResolver/tree/1.10.0"
|
||||||
|
},
|
||||||
|
"time": "2024-11-09T15:12:26+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "phpstan/phpdoc-parser",
|
||||||
|
"version": "2.0.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/phpstan/phpdoc-parser.git",
|
||||||
|
"reference": "c00d78fb6b29658347f9d37ebe104bffadf36299"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/c00d78fb6b29658347f9d37ebe104bffadf36299",
|
||||||
|
"reference": "c00d78fb6b29658347f9d37ebe104bffadf36299",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^7.4 || ^8.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"doctrine/annotations": "^2.0",
|
||||||
|
"nikic/php-parser": "^5.3.0",
|
||||||
|
"php-parallel-lint/php-parallel-lint": "^1.2",
|
||||||
|
"phpstan/extension-installer": "^1.0",
|
||||||
|
"phpstan/phpstan": "^2.0",
|
||||||
|
"phpstan/phpstan-phpunit": "^2.0",
|
||||||
|
"phpstan/phpstan-strict-rules": "^2.0",
|
||||||
|
"phpunit/phpunit": "^9.6",
|
||||||
|
"symfony/process": "^5.2"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"PHPStan\\PhpDocParser\\": [
|
||||||
|
"src/"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"description": "PHPDoc parser with support for nullable, intersection and generic types",
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/phpstan/phpdoc-parser/issues",
|
||||||
|
"source": "https://github.com/phpstan/phpdoc-parser/tree/2.0.0"
|
||||||
|
},
|
||||||
|
"time": "2024-10-13T11:29:49+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "psr/cache",
|
"name": "psr/cache",
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
@ -4543,16 +4841,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/property-access",
|
"name": "symfony/property-access",
|
||||||
"version": "v7.2.0",
|
"version": "v7.2.3",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/property-access.git",
|
"url": "https://github.com/symfony/property-access.git",
|
||||||
"reference": "3ae42efba01e45aaedecf5c93c8d6a3ab3a82276"
|
"reference": "b28732e315d81fbec787f838034de7d6c9b2b902"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/property-access/zipball/3ae42efba01e45aaedecf5c93c8d6a3ab3a82276",
|
"url": "https://api.github.com/repos/symfony/property-access/zipball/b28732e315d81fbec787f838034de7d6c9b2b902",
|
||||||
"reference": "3ae42efba01e45aaedecf5c93c8d6a3ab3a82276",
|
"reference": "b28732e315d81fbec787f838034de7d6c9b2b902",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -4599,7 +4897,7 @@
|
|||||||
"reflection"
|
"reflection"
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"source": "https://github.com/symfony/property-access/tree/v7.2.0"
|
"source": "https://github.com/symfony/property-access/tree/v7.2.3"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@ -4615,20 +4913,20 @@
|
|||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2024-09-26T12:28:35+00:00"
|
"time": "2025-01-17T10:56:55+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/property-info",
|
"name": "symfony/property-info",
|
||||||
"version": "v7.2.2",
|
"version": "v7.2.3",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/property-info.git",
|
"url": "https://github.com/symfony/property-info.git",
|
||||||
"reference": "1dfeb0dac7a99f7b3be42db9ccc299c5a6483fcf"
|
"reference": "dedb118fd588a92f226b390250b384d25f4192fe"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/property-info/zipball/1dfeb0dac7a99f7b3be42db9ccc299c5a6483fcf",
|
"url": "https://api.github.com/repos/symfony/property-info/zipball/dedb118fd588a92f226b390250b384d25f4192fe",
|
||||||
"reference": "1dfeb0dac7a99f7b3be42db9ccc299c5a6483fcf",
|
"reference": "dedb118fd588a92f226b390250b384d25f4192fe",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -4639,7 +4937,9 @@
|
|||||||
"conflict": {
|
"conflict": {
|
||||||
"phpdocumentor/reflection-docblock": "<5.2",
|
"phpdocumentor/reflection-docblock": "<5.2",
|
||||||
"phpdocumentor/type-resolver": "<1.5.1",
|
"phpdocumentor/type-resolver": "<1.5.1",
|
||||||
"symfony/dependency-injection": "<6.4"
|
"symfony/cache": "<6.4",
|
||||||
|
"symfony/dependency-injection": "<6.4",
|
||||||
|
"symfony/serializer": "<6.4"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpdocumentor/reflection-docblock": "^5.2",
|
"phpdocumentor/reflection-docblock": "^5.2",
|
||||||
@ -4682,7 +4982,7 @@
|
|||||||
"validator"
|
"validator"
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"source": "https://github.com/symfony/property-info/tree/v7.2.2"
|
"source": "https://github.com/symfony/property-info/tree/v7.2.3"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@ -4698,7 +4998,7 @@
|
|||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2024-12-31T11:04:50+00:00"
|
"time": "2025-01-27T11:08:17+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/routing",
|
"name": "symfony/routing",
|
||||||
@ -6412,6 +6712,64 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2024-12-29T10:51:50+00:00"
|
"time": "2024-12-29T10:51:50+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "webmozart/assert",
|
||||||
|
"version": "1.11.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/webmozarts/assert.git",
|
||||||
|
"reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/webmozarts/assert/zipball/11cb2199493b2f8a3b53e7f19068fc6aac760991",
|
||||||
|
"reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-ctype": "*",
|
||||||
|
"php": "^7.2 || ^8.0"
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"phpstan/phpstan": "<0.12.20",
|
||||||
|
"vimeo/psalm": "<4.6.1 || 4.6.2"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "^8.5.13"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "1.10-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Webmozart\\Assert\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Bernhard Schussek",
|
||||||
|
"email": "bschussek@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Assertions to validate method input/output with nice error messages.",
|
||||||
|
"keywords": [
|
||||||
|
"assert",
|
||||||
|
"check",
|
||||||
|
"validate"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/webmozarts/assert/issues",
|
||||||
|
"source": "https://github.com/webmozarts/assert/tree/1.11.0"
|
||||||
|
},
|
||||||
|
"time": "2022-06-03T18:03:27+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [
|
"packages-dev": [
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\DataObjects\TicketData;
|
use App\DataObjects\TicketFormData;
|
||||||
use App\Form\TicketForm;
|
use App\Repository\PaymentRepository;
|
||||||
use App\Service\TicketService;
|
use App\Service\TicketService;
|
||||||
use Stripe\Stripe;
|
use Stripe\Stripe;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
@ -17,15 +17,14 @@ final class TicketController extends AbstractController
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
private TicketService $service,
|
private TicketService $service,
|
||||||
private SerializerInterface $serializer,
|
private SerializerInterface $serializer,
|
||||||
|
private PaymentRepository $repository,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/ticket', name: 'app_ticket')]
|
#[Route('/ticket', name: 'app_ticket')]
|
||||||
public function index(): Response
|
public function index(): Response
|
||||||
{
|
{
|
||||||
return $this->render('ticket/index.html.twig', [
|
return $this->render('ticket/index.html.twig');
|
||||||
'form' => $this->createForm(TicketForm::class)->createView(),
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route(path: '/ticket/submit', name: 'app_submit', methods: Request::METHOD_POST)]
|
#[Route(path: '/ticket/submit', name: 'app_submit', methods: Request::METHOD_POST)]
|
||||||
@ -33,21 +32,15 @@ final class TicketController extends AbstractController
|
|||||||
{
|
{
|
||||||
Stripe::setApiKey($_ENV['STRIPE_SECRET_KEY']);
|
Stripe::setApiKey($_ENV['STRIPE_SECRET_KEY']);
|
||||||
|
|
||||||
/** @var TicketData[] $ticketData */
|
$ticketData = $this->serializer->deserialize($request->getContent(), TicketFormData::class, 'json');
|
||||||
$ticketData = $this->serializer->deserialize(
|
|
||||||
$request->getContent(),
|
|
||||||
TicketData::class.'[]',
|
|
||||||
'json',
|
|
||||||
['disable_type_enforcement' => true]
|
|
||||||
);
|
|
||||||
|
|
||||||
return $this->json(['id' => $this->service->handleTicketData($ticketData)->id]);
|
return $this->json(['id' => $this->service->handleTicketData($ticketData)->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route(path: '/success', name: 'app_success', methods: Request::METHOD_GET)]
|
#[Route(path: '/success', name: 'app_success', methods: Request::METHOD_GET)]
|
||||||
public function success(): Response
|
public function success(Request $request): Response
|
||||||
{
|
{
|
||||||
$this->service->saveTicketData();
|
$payment = $this->repository->findOneBy(['sessionId' => $request->query->get('session_id')]);
|
||||||
|
|
||||||
return $this->render('ticket/success.html.twig');
|
return $this->render('ticket/success.html.twig');
|
||||||
}
|
}
|
||||||
|
14
src/DataObjects/PersonalData.php
Normal file
14
src/DataObjects/PersonalData.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\DataObjects;
|
||||||
|
|
||||||
|
class PersonalData
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
public string $firstname,
|
||||||
|
public string $lastname,
|
||||||
|
public string $email,
|
||||||
|
public string $phone,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
}
|
20
src/DataObjects/TicketFormData.php
Normal file
20
src/DataObjects/TicketFormData.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\DataObjects;
|
||||||
|
|
||||||
|
use Symfony\Component\Serializer\Attribute\SerializedName;
|
||||||
|
|
||||||
|
class TicketFormData
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param PersonalData $personal
|
||||||
|
* @param TicketData[] $tickets
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
#[SerializedName('personal')]
|
||||||
|
public PersonalData $personal,
|
||||||
|
#[SerializedName('tickets')]
|
||||||
|
public array $tickets,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
}
|
152
src/Entity/Customer.php
Normal file
152
src/Entity/Customer.php
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use App\Repository\CustomerRepository;
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
use Doctrine\Common\Collections\Collection;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
#[ORM\Entity(repositoryClass: CustomerRepository::class)]
|
||||||
|
class Customer
|
||||||
|
{
|
||||||
|
#[ORM\Id]
|
||||||
|
#[ORM\GeneratedValue]
|
||||||
|
#[ORM\Column]
|
||||||
|
private ?int $id = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?string $email = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?string $phone = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?string $firstname = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?string $lastname = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Collection<int, Ticket>
|
||||||
|
*/
|
||||||
|
#[ORM\OneToMany(targetEntity: Ticket::class, mappedBy: 'customer', cascade: ['persist'], fetch: 'EAGER', orphanRemoval: true)]
|
||||||
|
private Collection $tickets;
|
||||||
|
|
||||||
|
#[ORM\OneToOne(mappedBy: 'customer', cascade: ['persist', 'remove'])]
|
||||||
|
private ?Payment $payment = null;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->tickets = new ArrayCollection();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getId(): ?int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEmail(): ?string
|
||||||
|
{
|
||||||
|
return $this->email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setEmail(string $email): static
|
||||||
|
{
|
||||||
|
$this->email = $email;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPhone(): ?string
|
||||||
|
{
|
||||||
|
return $this->phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPhone(?string $phone): static
|
||||||
|
{
|
||||||
|
$this->phone = $phone;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection<int, Ticket>
|
||||||
|
*/
|
||||||
|
public function getTickets(): Collection
|
||||||
|
{
|
||||||
|
return $this->tickets;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addTicket(Ticket $ticket): static
|
||||||
|
{
|
||||||
|
if (!$this->tickets->contains($ticket)) {
|
||||||
|
$this->tickets->add($ticket);
|
||||||
|
$ticket->setCustomer($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeTicket(Ticket $ticket): static
|
||||||
|
{
|
||||||
|
if ($this->tickets->removeElement($ticket)) {
|
||||||
|
// set the owning side to null (unless already changed)
|
||||||
|
if ($ticket->getCustomer() === $this) {
|
||||||
|
$ticket->setCustomer(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addTickets(array $tickets): static
|
||||||
|
{
|
||||||
|
foreach ($tickets as $ticket) {
|
||||||
|
$this->addTicket($ticket);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPayment(): ?Payment
|
||||||
|
{
|
||||||
|
return $this->payment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPayment(Payment $payment): static
|
||||||
|
{
|
||||||
|
// set the owning side of the relation if necessary
|
||||||
|
if ($payment->getCustomer() !== $this) {
|
||||||
|
$payment->setCustomer($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->payment = $payment;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
66
src/Entity/Payment.php
Normal file
66
src/Entity/Payment.php
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use App\Repository\PaymentRepository;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
#[ORM\Entity(repositoryClass: PaymentRepository::class)]
|
||||||
|
class Payment
|
||||||
|
{
|
||||||
|
#[ORM\Id]
|
||||||
|
#[ORM\GeneratedValue]
|
||||||
|
#[ORM\Column]
|
||||||
|
private ?int $id = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255)]
|
||||||
|
private ?string $sessionId = null;
|
||||||
|
|
||||||
|
#[ORM\Column]
|
||||||
|
private ?bool $completed = null;
|
||||||
|
|
||||||
|
#[ORM\OneToOne(inversedBy: 'payment', cascade: ['persist', 'remove'], fetch: 'EAGER')]
|
||||||
|
#[ORM\JoinColumn(nullable: false)]
|
||||||
|
private ?Customer $customer = null;
|
||||||
|
|
||||||
|
public function getId(): ?int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSessionId(): ?string
|
||||||
|
{
|
||||||
|
return $this->sessionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSessionId(string $sessionId): static
|
||||||
|
{
|
||||||
|
$this->sessionId = $sessionId;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isCompleted(): ?bool
|
||||||
|
{
|
||||||
|
return $this->completed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCompleted(bool $completed): static
|
||||||
|
{
|
||||||
|
$this->completed = $completed;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCustomer(): ?Customer
|
||||||
|
{
|
||||||
|
return $this->customer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCustomer(Customer $customer): static
|
||||||
|
{
|
||||||
|
$this->customer = $customer;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
@ -13,82 +13,68 @@ class Ticket
|
|||||||
#[ORM\Column]
|
#[ORM\Column]
|
||||||
private ?int $id = null;
|
private ?int $id = null;
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
#[ORM\Column]
|
||||||
private ?string $email = null;
|
private ?int $type = null;
|
||||||
|
|
||||||
#[ORM\Column(length: 255, nullable: true)]
|
|
||||||
private ?string $phone = null;
|
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
|
||||||
private ?string $firstname = null;
|
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
|
||||||
private ?string $lastname = null;
|
|
||||||
|
|
||||||
#[ORM\Column]
|
#[ORM\Column]
|
||||||
private int $quantity = 0;
|
private ?int $foodType = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?string $note = null;
|
||||||
|
|
||||||
|
#[ORM\ManyToOne(inversedBy: 'tickets')]
|
||||||
|
#[ORM\JoinColumn(nullable: false)]
|
||||||
|
private ?Customer $customer = null;
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEmail(): ?string
|
public function getType(): ?int
|
||||||
{
|
{
|
||||||
return $this->email;
|
return $this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setEmail(string $email): static
|
public function setType(int $type): static
|
||||||
{
|
{
|
||||||
$this->email = $email;
|
$this->type = $type;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPhone(): ?string
|
public function getFoodType(): ?int
|
||||||
{
|
{
|
||||||
return $this->phone;
|
return $this->foodType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setPhone(?string $phone): static
|
public function setFoodType(int $foodType): static
|
||||||
{
|
{
|
||||||
$this->phone = $phone;
|
$this->foodType = $foodType;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFirstname(): ?string
|
public function getNote(): ?string
|
||||||
{
|
{
|
||||||
return $this->firstname;
|
return $this->note;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setFirstname(string $firstname): static
|
public function setNote(?string $note): static
|
||||||
{
|
{
|
||||||
$this->firstname = $firstname;
|
$this->note = $note;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLastname(): ?string
|
public function getCustomer(): ?Customer
|
||||||
{
|
{
|
||||||
return $this->lastname;
|
return $this->customer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setLastname(string $lastname): static
|
public function setCustomer(?Customer $customer): static
|
||||||
{
|
{
|
||||||
$this->lastname = $lastname;
|
$this->customer = $customer;
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getQuantity(): int
|
|
||||||
{
|
|
||||||
return $this->quantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setQuantity(int $quantity): static
|
|
||||||
{
|
|
||||||
$this->quantity = $quantity;
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -5,19 +5,19 @@ namespace App\Enum;
|
|||||||
class TicketData
|
class TicketData
|
||||||
{
|
{
|
||||||
public const TICKET_DATA = [
|
public const TICKET_DATA = [
|
||||||
0 => [
|
1 => [
|
||||||
'name' => 'Ticket',
|
'name' => 'Ticket',
|
||||||
'price' => 50,
|
'price' => 50,
|
||||||
],
|
],
|
||||||
1 => [
|
2 => [
|
||||||
'name' => 'After-Show Ticket',
|
'name' => 'After-Show Ticket',
|
||||||
'price' => 20,
|
'price' => 20,
|
||||||
],
|
],
|
||||||
2 => [
|
3 => [
|
||||||
'name' => 'Kind (6-12 Jahre)',
|
'name' => 'Kind (6-12 Jahre)',
|
||||||
'price' => 0,
|
'price' => 0,
|
||||||
],
|
],
|
||||||
3 => [
|
4 => [
|
||||||
'name' => 'Kind (0-6 Jahre)',
|
'name' => 'Kind (0-6 Jahre)',
|
||||||
'price' => 0,
|
'price' => 0,
|
||||||
],
|
],
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Form;
|
|
||||||
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
|
||||||
|
|
||||||
class TicketForm extends AbstractType
|
|
||||||
{
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
|
||||||
{
|
|
||||||
$builder;
|
|
||||||
}
|
|
||||||
}
|
|
18
src/Repository/CustomerRepository.php
Normal file
18
src/Repository/CustomerRepository.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repository;
|
||||||
|
|
||||||
|
use App\Entity\Customer;
|
||||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends ServiceEntityRepository<Customer>
|
||||||
|
*/
|
||||||
|
class CustomerRepository extends ServiceEntityRepository
|
||||||
|
{
|
||||||
|
public function __construct(ManagerRegistry $registry)
|
||||||
|
{
|
||||||
|
parent::__construct($registry, Customer::class);
|
||||||
|
}
|
||||||
|
}
|
18
src/Repository/PaymentRepository.php
Normal file
18
src/Repository/PaymentRepository.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repository;
|
||||||
|
|
||||||
|
use App\Entity\Payment;
|
||||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends ServiceEntityRepository<Payment>
|
||||||
|
*/
|
||||||
|
class PaymentRepository extends ServiceEntityRepository
|
||||||
|
{
|
||||||
|
public function __construct(ManagerRegistry $registry)
|
||||||
|
{
|
||||||
|
parent::__construct($registry, Payment::class);
|
||||||
|
}
|
||||||
|
}
|
@ -15,29 +15,4 @@ class TicketRepository extends ServiceEntityRepository
|
|||||||
{
|
{
|
||||||
parent::__construct($registry, Ticket::class);
|
parent::__construct($registry, Ticket::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @return Ticket[] Returns an array of Ticket objects
|
|
||||||
// */
|
|
||||||
// public function findByExampleField($value): array
|
|
||||||
// {
|
|
||||||
// return $this->createQueryBuilder('t')
|
|
||||||
// ->andWhere('t.exampleField = :val')
|
|
||||||
// ->setParameter('val', $value)
|
|
||||||
// ->orderBy('t.id', 'ASC')
|
|
||||||
// ->setMaxResults(10)
|
|
||||||
// ->getQuery()
|
|
||||||
// ->getResult()
|
|
||||||
// ;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public function findOneBySomeField($value): ?Ticket
|
|
||||||
// {
|
|
||||||
// return $this->createQueryBuilder('t')
|
|
||||||
// ->andWhere('t.exampleField = :val')
|
|
||||||
// ->setParameter('val', $value)
|
|
||||||
// ->getQuery()
|
|
||||||
// ->getOneOrNullResult()
|
|
||||||
// ;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
@ -3,29 +3,50 @@
|
|||||||
namespace App\Service;
|
namespace App\Service;
|
||||||
|
|
||||||
use App\DataObjects\TicketData;
|
use App\DataObjects\TicketData;
|
||||||
|
use App\DataObjects\TicketFormData;
|
||||||
|
use App\Entity\Customer;
|
||||||
|
use App\Entity\Payment;
|
||||||
|
use App\Entity\Ticket;
|
||||||
use App\Enum\TicketData as TicketEnum;
|
use App\Enum\TicketData as TicketEnum;
|
||||||
|
use Cassandra\Custom;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Stripe\Checkout\Session;
|
use Stripe\Checkout\Session;
|
||||||
use Symfony\Component\HttpFoundation\RequestStack;
|
|
||||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||||
|
|
||||||
class TicketService
|
class TicketService
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly UrlGeneratorInterface $generator,
|
private readonly UrlGeneratorInterface $generator,
|
||||||
private readonly RequestStack $requestStack,
|
private readonly EntityManagerInterface $em,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function handleTicketData(TicketFormData $data): Session
|
||||||
* @param TicketData[] $data
|
|
||||||
*/
|
|
||||||
public function handleTicketData(array $data): Session
|
|
||||||
{
|
{
|
||||||
$this->requestStack->getSession()->set('ticketData', $data);
|
$session = $this->createSession($this->getLineItems($data->tickets), $data->personal->email);
|
||||||
|
|
||||||
|
$this->saveTicketData($data, $session->id);
|
||||||
|
|
||||||
|
return $session;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function saveTicketData(TicketFormData $data, string $sessionId): void
|
||||||
|
{
|
||||||
|
$payment = (new Payment())
|
||||||
|
->setSessionId($sessionId)
|
||||||
|
->setCompleted(false)
|
||||||
|
->setCustomer($this->createEntityFromData($data));
|
||||||
|
|
||||||
|
$this->em->persist($payment);
|
||||||
|
$this->em->flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function getLineItems(array $tickets): array
|
||||||
|
{
|
||||||
$lineItems = [];
|
$lineItems = [];
|
||||||
|
|
||||||
foreach ($data as $ticket) {
|
foreach ($tickets as $ticket) {
|
||||||
$ticketData = TicketEnum::TICKET_DATA[$ticket->ticketType];
|
$ticketData = TicketEnum::TICKET_DATA[$ticket->ticketType];
|
||||||
$lineItems[] = [
|
$lineItems[] = [
|
||||||
'price_data' => [
|
'price_data' => [
|
||||||
@ -39,18 +60,52 @@ class TicketService
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $lineItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function createSession(array $lineItems, string $email): Session
|
||||||
|
{
|
||||||
return Session::create([
|
return Session::create([
|
||||||
'line_items' => $lineItems,
|
'line_items' => $lineItems,
|
||||||
'mode' => 'payment',
|
'mode' => 'payment',
|
||||||
'success_url' => $this->generator->generate('app_success', [], 0),
|
'customer_email' => $email,
|
||||||
|
'success_url' => $this->generator->generate('app_success', [], 0) . '?session_id={CHECKOUT_SESSION_ID}',
|
||||||
'cancel_url' => $this->generator->generate('app_cancelled', [], 0),
|
'cancel_url' => $this->generator->generate('app_cancelled', [], 0),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function saveTicketData()
|
private function createEntityFromData(TicketFormData $ticketData): Customer
|
||||||
{
|
{
|
||||||
$ticketData = $this->requestStack->getSession()->get('ticketData');
|
$personalData = $ticketData->personal;
|
||||||
|
|
||||||
|
$entity = (new Customer())
|
||||||
|
->setFirstname($personalData->firstname)
|
||||||
|
->setLastname($personalData->lastname)
|
||||||
|
->setEmail($personalData->email)
|
||||||
|
->setPhone($personalData->phone);
|
||||||
|
|
||||||
|
$entity->addTickets($this->createTicketEntities($ticketData->tickets));
|
||||||
|
|
||||||
|
$this->em->persist($entity);
|
||||||
|
$this->em->flush();
|
||||||
|
|
||||||
|
return $entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param TicketData[] $tickets
|
||||||
|
*/
|
||||||
|
private function createTicketEntities(array $tickets): array
|
||||||
|
{
|
||||||
|
$entities = [];
|
||||||
|
|
||||||
|
foreach ($tickets as $ticket) {
|
||||||
|
$entities[] = (new Ticket())
|
||||||
|
->setType($ticket->ticketType)
|
||||||
|
->setFoodType($ticket->foodType)
|
||||||
|
->setNote($ticket->note);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $entities;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,13 @@
|
|||||||
{
|
{
|
||||||
|
"doctrine/annotations": {
|
||||||
|
"version": "2.0",
|
||||||
|
"recipe": {
|
||||||
|
"repo": "github.com/symfony/recipes",
|
||||||
|
"branch": "main",
|
||||||
|
"version": "1.10",
|
||||||
|
"ref": "64d8583af5ea57b7afa4aba4b159907f3a148b05"
|
||||||
|
}
|
||||||
|
},
|
||||||
"doctrine/doctrine-bundle": {
|
"doctrine/doctrine-bundle": {
|
||||||
"version": "2.13",
|
"version": "2.13",
|
||||||
"recipe": {
|
"recipe": {
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<option value="2">Vegetarisch</option>
|
<option value="2">Vegetarisch</option>
|
||||||
<option value="3">Vegan</option>
|
<option value="3">Vegan</option>
|
||||||
</select>
|
</select>
|
||||||
<input type="text" placeholder="z.B. Allergien" name="note" class="w-1/3 bg-white/90 text-gray-800 font-medium text-sm sm:text-base px-4 sm:px-6 py-2 sm:py-3 rounded-full border border-gray-100 focus:outline-none focus:ring-2 focus:ring-red-500 focus:border-transparent transition-all duration-300 mr-2" />
|
<input type="text" placeholder="z.B. Allergien" name="note" class="w-1/3 text-input mr-2" />
|
||||||
<button data-action="form#removeEntry" class="w-1/6"><twig:ux:icon name="delete" class="ml-5" height="27px" width="27px" /></button>
|
<button data-action="form#removeEntry" class="w-1/6"><twig:ux:icon name="delete" class="ml-5" height="27px" width="27px" /></button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
@ -23,6 +23,24 @@
|
|||||||
<div class="bg-white/80 backdrop-blur-md shadow-xl rounded-2xl sm:rounded-3xl p-6 sm:p-8 md:p-10 mb-12 sm:mb-16 transform transition-all duration-300 border border-gray-100">
|
<div class="bg-white/80 backdrop-blur-md shadow-xl rounded-2xl sm:rounded-3xl p-6 sm:p-8 md:p-10 mb-12 sm:mb-16 transform transition-all duration-300 border border-gray-100">
|
||||||
<div data-controller="form">
|
<div data-controller="form">
|
||||||
<div class="hidden" data-form-target="key">{{ env('STRIPE_PUBLIC_KEY')}}</div>
|
<div class="hidden" data-form-target="key">{{ env('STRIPE_PUBLIC_KEY')}}</div>
|
||||||
|
|
||||||
|
<h2 class="text-2xl mb-5">Persönliche Daten</h2>
|
||||||
|
|
||||||
|
<div class="mb-5 w-full">
|
||||||
|
<div class="flex inline-flex mb-5 w-full">
|
||||||
|
<input name="firstname" data-form-target="firstname" class="w-1/2 text-input mr-2 py-2" type="text" placeholder="Vorname*" required>
|
||||||
|
<input name="firstname" data-form-target="lastname" class="w-1/2 text-input mr-2 py-2" type="text" placeholder="Nachname*" required>
|
||||||
|
</div>
|
||||||
|
<div class="flex inline-flex mb-5 w-full">
|
||||||
|
<input name="firstname" data-form-target="email" class="w-1/2 text-input mr-2 py-2" type="email" placeholder="E-Mail*" required>
|
||||||
|
<input name="firstname" data-form-target="phone" class="w-1/2 text-input mr-2 py-2" type="tel" placeholder="Telefon">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr class="my-6 border-t border-gray-900" />
|
||||||
|
|
||||||
|
<h2 class="text-2xl mb-5">Tickets</h2>
|
||||||
|
|
||||||
<div class="w-full flex inline-flex mb-5">
|
<div class="w-full flex inline-flex mb-5">
|
||||||
<div class="w-1/4 ml-6">Ticket</div>
|
<div class="w-1/4 ml-6">Ticket</div>
|
||||||
<div class="w-1/4 ml-5">Ernährung</div>
|
<div class="w-1/4 ml-5">Ernährung</div>
|
||||||
@ -30,7 +48,7 @@
|
|||||||
<div class="w-1/6 text-center"></div>
|
<div class="w-1/6 text-center"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="forms">
|
<div class="forms">
|
||||||
{% include 'ticket/_partials/_form.html.twig' with {form: form} %}
|
{% include 'ticket/_partials/_form.html.twig' %}
|
||||||
</div>
|
</div>
|
||||||
<div class="flex inline-flex w-full">
|
<div class="flex inline-flex w-full">
|
||||||
<button class="ml-0" data-action="form#addEntry" type="button"><twig:ux:icon name="plus" height="32px" width="32px"/></button>
|
<button class="ml-0" data-action="form#addEntry" type="button"><twig:ux:icon name="plus" height="32px" width="32px"/></button>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user