bumpi
This commit is contained in:
parent
bbc56a9af7
commit
1f9562d36b
13 changed files with 525 additions and 507 deletions
|
@ -15,7 +15,6 @@
|
|||
"doctrine/orm": "^3.4.0",
|
||||
"nelmio/cors-bundle": "^2.5",
|
||||
"phpdocumentor/reflection-docblock": "^5.6.2",
|
||||
"phpstan/phpdoc-parser": "^1.33",
|
||||
"psr/clock": "^1.0",
|
||||
"symfony/asset": "7.3.*",
|
||||
"symfony/asset-mapper": "7.3.*",
|
||||
|
@ -42,7 +41,7 @@
|
|||
"require-dev": {
|
||||
"doctrine/doctrine-fixtures-bundle": "^4.1",
|
||||
"liip/test-fixtures-bundle": "^3.4",
|
||||
"lubiana/code-quality": "^1.7.2",
|
||||
"lubiana/code-quality": "1.7.3",
|
||||
"pestphp/pest": "^3.8.2",
|
||||
"symfony/browser-kit": "7.3.*",
|
||||
"symfony/css-selector": "7.3.*",
|
||||
|
|
151
composer.lock
generated
151
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "923bae46e3b7f783b6c25f8f68f97991",
|
||||
"content-hash": "bc8674fb48687aeee3da991cd7c8d0ad",
|
||||
"packages": [
|
||||
{
|
||||
"name": "api-platform/core",
|
||||
|
@ -1764,30 +1764,30 @@
|
|||
},
|
||||
{
|
||||
"name": "phpstan/phpdoc-parser",
|
||||
"version": "1.33.0",
|
||||
"version": "2.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpstan/phpdoc-parser.git",
|
||||
"reference": "82a311fd3690fb2bf7b64d5c98f912b3dd746140"
|
||||
"reference": "9b30d6fd026b2c132b3985ce6b23bec09ab3aa68"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/82a311fd3690fb2bf7b64d5c98f912b3dd746140",
|
||||
"reference": "82a311fd3690fb2bf7b64d5c98f912b3dd746140",
|
||||
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/9b30d6fd026b2c132b3985ce6b23bec09ab3aa68",
|
||||
"reference": "9b30d6fd026b2c132b3985ce6b23bec09ab3aa68",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2 || ^8.0"
|
||||
"php": "^7.4 || ^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/annotations": "^2.0",
|
||||
"nikic/php-parser": "^4.15",
|
||||
"nikic/php-parser": "^5.3.0",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.2",
|
||||
"phpstan/extension-installer": "^1.0",
|
||||
"phpstan/phpstan": "^1.5",
|
||||
"phpstan/phpstan-phpunit": "^1.1",
|
||||
"phpstan/phpstan-strict-rules": "^1.0",
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"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",
|
||||
|
@ -1805,9 +1805,9 @@
|
|||
"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/1.33.0"
|
||||
"source": "https://github.com/phpstan/phpdoc-parser/tree/2.1.0"
|
||||
},
|
||||
"time": "2024-10-13T11:25:22+00:00"
|
||||
"time": "2025-02-19T13:28:12+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/cache",
|
||||
|
@ -7031,28 +7031,28 @@
|
|||
},
|
||||
{
|
||||
"name": "dealerdirect/phpcodesniffer-composer-installer",
|
||||
"version": "v1.0.0",
|
||||
"version": "v1.1.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHPCSStandards/composer-installer.git",
|
||||
"reference": "4be43904336affa5c2f70744a348312336afd0da"
|
||||
"reference": "6e0fa428497bf560152ee73ffbb8af5c6a56b0dd"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/4be43904336affa5c2f70744a348312336afd0da",
|
||||
"reference": "4be43904336affa5c2f70744a348312336afd0da",
|
||||
"url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/6e0fa428497bf560152ee73ffbb8af5c6a56b0dd",
|
||||
"reference": "6e0fa428497bf560152ee73ffbb8af5c6a56b0dd",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"composer-plugin-api": "^1.0 || ^2.0",
|
||||
"composer-plugin-api": "^2.2",
|
||||
"php": ">=5.4",
|
||||
"squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"composer/composer": "*",
|
||||
"composer/composer": "^2.2",
|
||||
"ext-json": "*",
|
||||
"ext-zip": "*",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.3.1",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.4.0",
|
||||
"phpcompatibility/php-compatibility": "^9.0",
|
||||
"yoast/phpunit-polyfills": "^1.0"
|
||||
},
|
||||
|
@ -7072,9 +7072,9 @@
|
|||
"authors": [
|
||||
{
|
||||
"name": "Franck Nijhof",
|
||||
"email": "franck.nijhof@dealerdirect.com",
|
||||
"homepage": "http://www.frenck.nl",
|
||||
"role": "Developer / IT Manager"
|
||||
"email": "opensource@frenck.dev",
|
||||
"homepage": "https://frenck.dev",
|
||||
"role": "Open source developer"
|
||||
},
|
||||
{
|
||||
"name": "Contributors",
|
||||
|
@ -7082,7 +7082,6 @@
|
|||
}
|
||||
],
|
||||
"description": "PHP_CodeSniffer Standards Composer Installer Plugin",
|
||||
"homepage": "http://www.dealerdirect.com",
|
||||
"keywords": [
|
||||
"PHPCodeSniffer",
|
||||
"PHP_CodeSniffer",
|
||||
|
@ -7103,9 +7102,28 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/PHPCSStandards/composer-installer/issues",
|
||||
"security": "https://github.com/PHPCSStandards/composer-installer/security/policy",
|
||||
"source": "https://github.com/PHPCSStandards/composer-installer"
|
||||
},
|
||||
"time": "2023-01-05T11:28:13+00:00"
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/PHPCSStandards",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/jrfnl",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://opencollective.com/php_codesniffer",
|
||||
"type": "open_collective"
|
||||
},
|
||||
{
|
||||
"url": "https://thanks.dev/u/gh/phpcsstandards",
|
||||
"type": "thanks_dev"
|
||||
}
|
||||
],
|
||||
"time": "2025-06-27T17:24:01+00:00"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/data-fixtures",
|
||||
|
@ -7557,17 +7575,17 @@
|
|||
},
|
||||
{
|
||||
"name": "lubiana/code-quality",
|
||||
"version": "1.7.2",
|
||||
"version": "1.7.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://git.php.fail/lubiana/code-quality.git",
|
||||
"reference": "b7e3418f0fa3225d2cdab9cfdcba266bc74775a4"
|
||||
"reference": "85f220919f8b478eb25ca0ca1028f045b8f0c4c4"
|
||||
},
|
||||
"require": {
|
||||
"php": "^8.3",
|
||||
"rector/rector": "^1.0.5",
|
||||
"slevomat/coding-standard": "^8.15",
|
||||
"symplify/easy-coding-standard": "^12.3.5"
|
||||
"rector/rector": "^2.1.0",
|
||||
"slevomat/coding-standard": "^8.19.1",
|
||||
"symplify/easy-coding-standard": "^12.5.20"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
|
@ -7582,7 +7600,7 @@
|
|||
"keywords": [
|
||||
"dev"
|
||||
],
|
||||
"time": "2024-08-18T07:17:23+00:00"
|
||||
"time": "2025-06-29T17:02:17+00:00"
|
||||
},
|
||||
{
|
||||
"name": "masterminds/html5",
|
||||
|
@ -8399,20 +8417,20 @@
|
|||
},
|
||||
{
|
||||
"name": "phpstan/phpstan",
|
||||
"version": "1.12.27",
|
||||
"version": "2.1.17",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpstan/phpstan.git",
|
||||
"reference": "3a6e423c076ab39dfedc307e2ac627ef579db162"
|
||||
"reference": "89b5ef665716fa2a52ecd2633f21007a6a349053"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/3a6e423c076ab39dfedc307e2ac627ef579db162",
|
||||
"reference": "3a6e423c076ab39dfedc307e2ac627ef579db162",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/89b5ef665716fa2a52ecd2633f21007a6a349053",
|
||||
"reference": "89b5ef665716fa2a52ecd2633f21007a6a349053",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2|^8.0"
|
||||
"php": "^7.4|^8.0"
|
||||
},
|
||||
"conflict": {
|
||||
"phpstan/phpstan-shim": "*"
|
||||
|
@ -8453,7 +8471,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2025-05-21T20:51:45+00:00"
|
||||
"time": "2025-05-21T20:55:28+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
|
@ -8932,21 +8950,21 @@
|
|||
},
|
||||
{
|
||||
"name": "rector/rector",
|
||||
"version": "1.2.10",
|
||||
"version": "2.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/rectorphp/rector.git",
|
||||
"reference": "40f9cf38c05296bd32f444121336a521a293fa61"
|
||||
"reference": "d513dea45a94394b660e15c155d1fa27826f8e30"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/rectorphp/rector/zipball/40f9cf38c05296bd32f444121336a521a293fa61",
|
||||
"reference": "40f9cf38c05296bd32f444121336a521a293fa61",
|
||||
"url": "https://api.github.com/repos/rectorphp/rector/zipball/d513dea45a94394b660e15c155d1fa27826f8e30",
|
||||
"reference": "d513dea45a94394b660e15c155d1fa27826f8e30",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2|^8.0",
|
||||
"phpstan/phpstan": "^1.12.5"
|
||||
"php": "^7.4|^8.0",
|
||||
"phpstan/phpstan": "^2.1.17"
|
||||
},
|
||||
"conflict": {
|
||||
"rector/rector-doctrine": "*",
|
||||
|
@ -8971,6 +8989,7 @@
|
|||
"MIT"
|
||||
],
|
||||
"description": "Instant Upgrade and Automated Refactoring of any PHP code",
|
||||
"homepage": "https://getrector.com/",
|
||||
"keywords": [
|
||||
"automation",
|
||||
"dev",
|
||||
|
@ -8979,7 +8998,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/rectorphp/rector/issues",
|
||||
"source": "https://github.com/rectorphp/rector/tree/1.2.10"
|
||||
"source": "https://github.com/rectorphp/rector/tree/2.1.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
@ -8987,7 +9006,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2024-11-08T13:59:10+00:00"
|
||||
"time": "2025-06-24T20:26:57+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/cli-parser",
|
||||
|
@ -9929,32 +9948,32 @@
|
|||
},
|
||||
{
|
||||
"name": "slevomat/coding-standard",
|
||||
"version": "8.15.0",
|
||||
"version": "8.19.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/slevomat/coding-standard.git",
|
||||
"reference": "7d1d957421618a3803b593ec31ace470177d7817"
|
||||
"reference": "458d665acd49009efebd7e0cb385d71ae9ac3220"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/slevomat/coding-standard/zipball/7d1d957421618a3803b593ec31ace470177d7817",
|
||||
"reference": "7d1d957421618a3803b593ec31ace470177d7817",
|
||||
"url": "https://api.github.com/repos/slevomat/coding-standard/zipball/458d665acd49009efebd7e0cb385d71ae9ac3220",
|
||||
"reference": "458d665acd49009efebd7e0cb385d71ae9ac3220",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0",
|
||||
"php": "^7.2 || ^8.0",
|
||||
"phpstan/phpdoc-parser": "^1.23.1",
|
||||
"squizlabs/php_codesniffer": "^3.9.0"
|
||||
"php": "^7.4 || ^8.0",
|
||||
"phpstan/phpdoc-parser": "^2.1.0",
|
||||
"squizlabs/php_codesniffer": "^3.13.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phing/phing": "2.17.4",
|
||||
"php-parallel-lint/php-parallel-lint": "1.3.2",
|
||||
"phpstan/phpstan": "1.10.60",
|
||||
"phpstan/phpstan-deprecation-rules": "1.1.4",
|
||||
"phpstan/phpstan-phpunit": "1.3.16",
|
||||
"phpstan/phpstan-strict-rules": "1.5.2",
|
||||
"phpunit/phpunit": "8.5.21|9.6.8|10.5.11"
|
||||
"phing/phing": "3.0.1",
|
||||
"php-parallel-lint/php-parallel-lint": "1.4.0",
|
||||
"phpstan/phpstan": "2.1.17",
|
||||
"phpstan/phpstan-deprecation-rules": "2.0.3",
|
||||
"phpstan/phpstan-phpunit": "2.0.6",
|
||||
"phpstan/phpstan-strict-rules": "2.0.4",
|
||||
"phpunit/phpunit": "9.6.8|10.5.45|11.4.4|11.5.21|12.1.3"
|
||||
},
|
||||
"type": "phpcodesniffer-standard",
|
||||
"extra": {
|
||||
|
@ -9978,7 +9997,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/slevomat/coding-standard/issues",
|
||||
"source": "https://github.com/slevomat/coding-standard/tree/8.15.0"
|
||||
"source": "https://github.com/slevomat/coding-standard/tree/8.19.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
@ -9990,20 +10009,20 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-03-09T15:20:58+00:00"
|
||||
"time": "2025-06-09T17:53:57+00:00"
|
||||
},
|
||||
{
|
||||
"name": "squizlabs/php_codesniffer",
|
||||
"version": "3.13.1",
|
||||
"version": "3.13.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git",
|
||||
"reference": "1b71b4dd7e7ef651ac749cea67e513c0c832f4bd"
|
||||
"reference": "5b5e3821314f947dd040c70f7992a64eac89025c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/1b71b4dd7e7ef651ac749cea67e513c0c832f4bd",
|
||||
"reference": "1b71b4dd7e7ef651ac749cea67e513c0c832f4bd",
|
||||
"url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/5b5e3821314f947dd040c70f7992a64eac89025c",
|
||||
"reference": "5b5e3821314f947dd040c70f7992a64eac89025c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -10074,7 +10093,7 @@
|
|||
"type": "thanks_dev"
|
||||
}
|
||||
],
|
||||
"time": "2025-06-12T15:04:34+00:00"
|
||||
"time": "2025-06-17T22:17:01+00:00"
|
||||
},
|
||||
{
|
||||
"name": "staabm/side-effects-detector",
|
||||
|
|
|
@ -14,22 +14,6 @@ use Symfony\Component\Routing\Attribute\Route;
|
|||
#[Route('/food/order')]
|
||||
final class FoodOrderController extends AbstractController
|
||||
{
|
||||
#[Route(
|
||||
path: '/list',
|
||||
name: 'app_food_order_index',
|
||||
methods: ['GET']
|
||||
)]
|
||||
public function index(FoodOrderRepository $foodOrderRepository): Response
|
||||
{
|
||||
|
||||
return $this->render('food_order/index.html.twig', [
|
||||
'food_orders' => $foodOrderRepository->findLatestEntries(days: 3),
|
||||
'current_page' => 0,
|
||||
'next_page' => 0,
|
||||
'prev_page' => 0,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route(
|
||||
path: '/list/archive/{page}',
|
||||
name: 'app_food_order_archive',
|
||||
|
@ -60,6 +44,32 @@ final class FoodOrderController extends AbstractController
|
|||
]);
|
||||
}
|
||||
|
||||
#[Route('/{id}/close', name: 'app_food_order_close', methods: ['GET'])]
|
||||
public function close(FoodOrder $foodOrder, FoodOrderRepository $repository): Response
|
||||
{
|
||||
$foodOrder->close();
|
||||
$repository->save();
|
||||
return $this->redirectToRoute('app_food_order_show', [
|
||||
'id' => $foodOrder->getId(),
|
||||
], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
#[Route(
|
||||
path: '/list',
|
||||
name: 'app_food_order_index',
|
||||
methods: ['GET']
|
||||
)]
|
||||
public function index(FoodOrderRepository $foodOrderRepository): Response
|
||||
{
|
||||
|
||||
return $this->render('food_order/index.html.twig', [
|
||||
'food_orders' => $foodOrderRepository->findLatestEntries(days: 3),
|
||||
'current_page' => 0,
|
||||
'next_page' => 0,
|
||||
'prev_page' => 0,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/new', name: 'app_food_order_new', methods: ['GET', 'POST'])]
|
||||
public function new(Request $request, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
|
@ -84,24 +94,6 @@ final class FoodOrderController extends AbstractController
|
|||
]);
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'app_food_order_show', methods: ['GET'])]
|
||||
public function show(FoodOrder $foodOrder): Response
|
||||
{
|
||||
return $this->render('food_order/show.html.twig', [
|
||||
'food_order' => $foodOrder,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/{id}/close', name: 'app_food_order_close', methods: ['GET'])]
|
||||
public function close(FoodOrder $foodOrder, FoodOrderRepository $repository): Response
|
||||
{
|
||||
$foodOrder->close();
|
||||
$repository->save();
|
||||
return $this->redirectToRoute('app_food_order_show', [
|
||||
'id' => $foodOrder->getId(),
|
||||
], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
#[Route('/{id}/open', name: 'app_food_order_open', methods: ['GET'])]
|
||||
public function open(FoodOrder $foodOrder, FoodOrderRepository $repository): Response
|
||||
{
|
||||
|
@ -111,4 +103,12 @@ final class FoodOrderController extends AbstractController
|
|||
'id' => $foodOrder->getId(),
|
||||
], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'app_food_order_show', methods: ['GET'])]
|
||||
public function show(FoodOrder $foodOrder): Response
|
||||
{
|
||||
return $this->render('food_order/show.html.twig', [
|
||||
'food_order' => $foodOrder,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,23 @@ use Symfony\Component\Routing\Attribute\Route;
|
|||
#[Route('/food/vendor')]
|
||||
final class FoodVendorController extends AbstractController
|
||||
{
|
||||
#[Route('/{id}/edit', name: 'app_food_vendor_edit', methods: ['GET', 'POST'])]
|
||||
public function edit(Request $request, FoodVendor $foodVendor, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$form = $this->createForm(FoodVendorType::class, $foodVendor);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_food_vendor_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
return $this->render('food_vendor/edit.html.twig', [
|
||||
'form' => $form,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/', name: 'app_food_vendor_index', methods: ['GET'])]
|
||||
public function index(FoodVendorRepository $foodVendorRepository): Response
|
||||
{
|
||||
|
@ -51,21 +68,4 @@ final class FoodVendorController extends AbstractController
|
|||
'food_vendor' => $foodVendor,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/{id}/edit', name: 'app_food_vendor_edit', methods: ['GET', 'POST'])]
|
||||
public function edit(Request $request, FoodVendor $foodVendor, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$form = $this->createForm(FoodVendorType::class, $foodVendor);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_food_vendor_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
return $this->render('food_vendor/edit.html.twig', [
|
||||
'form' => $form,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,12 +13,18 @@ use Symfony\Component\Routing\Attribute\Route;
|
|||
#[Route('/menu/item')]
|
||||
final class MenuItemController extends AbstractController
|
||||
{
|
||||
#[Route('/{id}', name: 'app_menu_item_show', methods: ['GET'])]
|
||||
public function show(MenuItem $menuItem): Response
|
||||
#[Route('/{id}', name: 'app_menu_item_delete', methods: ['POST'])]
|
||||
public function delete(Request $request, MenuItem $menuItem, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
return $this->render('menu_item/show.html.twig', [
|
||||
'menu_item' => $menuItem,
|
||||
]);
|
||||
if ($this->isCsrfTokenValid('delete' . $menuItem->getId(), $request->getPayload()->getString('_token'))) {
|
||||
$menuItem->delete();
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('app_food_vendor_show', [
|
||||
'id' => $menuItem->getFoodVendor()
|
||||
->getId(),
|
||||
], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
#[Route('/{id}/edit', name: 'app_menu_item_edit', methods: ['GET', 'POST'])]
|
||||
|
@ -52,17 +58,11 @@ final class MenuItemController extends AbstractController
|
|||
]);
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'app_menu_item_delete', methods: ['POST'])]
|
||||
public function delete(Request $request, MenuItem $menuItem, EntityManagerInterface $entityManager): Response
|
||||
#[Route('/{id}', name: 'app_menu_item_show', methods: ['GET'])]
|
||||
public function show(MenuItem $menuItem): Response
|
||||
{
|
||||
if ($this->isCsrfTokenValid('delete' . $menuItem->getId(), $request->getPayload()->getString('_token'))) {
|
||||
$menuItem->delete();
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('app_food_vendor_show', [
|
||||
'id' => $menuItem->getFoodVendor()
|
||||
->getId(),
|
||||
], Response::HTTP_SEE_OTHER);
|
||||
return $this->render('menu_item/show.html.twig', [
|
||||
'menu_item' => $menuItem,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,62 +16,6 @@ use Symfony\Component\Routing\Attribute\Route;
|
|||
#[Route('/order/item')]
|
||||
final class OrderItemController extends AbstractController
|
||||
{
|
||||
#[Route('/new/{foodOrder}', name: 'app_order_item_new', methods: ['GET', 'POST'])]
|
||||
public function new(Request $request, FoodOrder $foodOrder, EntityManagerInterface $entityManager, MenuItemRepository $menuItemRepository): Response
|
||||
{
|
||||
if ($foodOrder->isClosed()) {
|
||||
return $this->redirectToRoute('app_food_order_show', [
|
||||
'id' => $foodOrder->getId(),
|
||||
], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
$orderItem = new OrderItem;
|
||||
$username = $request->cookies->get('username', 'nobody');
|
||||
$orderItem->setCreatedBy($username);
|
||||
|
||||
$form = $this->createForm(OrderItemType::class, $orderItem);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$menuItem = $menuItemRepository->findOneBy([
|
||||
'name' => $orderItem->getName(),
|
||||
'foodVendor' => $foodOrder->getFoodVendor(),
|
||||
]);
|
||||
|
||||
if ($menuItem === null) {
|
||||
$menuItem = new MenuItem;
|
||||
$menuItem->setName($orderItem->getName());
|
||||
$menuItem->setFoodVendor($foodOrder->getFoodVendor());
|
||||
$entityManager->persist($menuItem);
|
||||
}
|
||||
|
||||
if ($menuItem->getAliasOf() !== null) {
|
||||
$menuItem = $menuItem->getAliasOf();
|
||||
$orderItem->setName($menuItem->getName());
|
||||
}
|
||||
|
||||
$orderItem->setMenuItem($menuItem);
|
||||
$orderItem->setFoodOrder($foodOrder);
|
||||
$entityManager->persist($orderItem);
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_food_order_show', [
|
||||
'id' => $foodOrder->getId(),
|
||||
], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
$menuItems = $menuItemRepository->findBy([
|
||||
'foodVendor' => $foodOrder->getFoodVendor(),
|
||||
'deletedAt' => null,
|
||||
]);
|
||||
|
||||
return $this->render('order_item/new.html.twig', [
|
||||
'order_item' => $orderItem,
|
||||
'food_order' => $foodOrder,
|
||||
'form' => $form,
|
||||
'menuItems' => $menuItems,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/{id}/copy', name: 'app_order_item_copy', methods: ['GET'])]
|
||||
public function copy(OrderItem $orderItem, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
|
@ -95,6 +39,23 @@ final class OrderItemController extends AbstractController
|
|||
], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
#[Route('/delete/{id}', name: 'app_order_item_delete')]
|
||||
public function delete(OrderItem $orderItem, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$foodOrder = $orderItem->getFoodOrder();
|
||||
if ($foodOrder->isClosed()) {
|
||||
return $this->redirectToRoute('app_food_order_show', [
|
||||
'id' => $foodOrder->getId(),
|
||||
], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
$entityManager->remove($orderItem);
|
||||
$entityManager->flush();
|
||||
return $this->redirectToRoute('app_food_order_show', [
|
||||
'id' => $orderItem->getFoodOrder()
|
||||
->getId(),
|
||||
], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
#[Route('/{id}/edit', name: 'app_order_item_edit', methods: ['GET', 'POST'])]
|
||||
public function edit(
|
||||
Request $request,
|
||||
|
@ -143,20 +104,59 @@ final class OrderItemController extends AbstractController
|
|||
]);
|
||||
}
|
||||
|
||||
#[Route('/delete/{id}', name: 'app_order_item_delete')]
|
||||
public function delete(OrderItem $orderItem, EntityManagerInterface $entityManager): Response
|
||||
#[Route('/new/{foodOrder}', name: 'app_order_item_new', methods: ['GET', 'POST'])]
|
||||
public function new(Request $request, FoodOrder $foodOrder, EntityManagerInterface $entityManager, MenuItemRepository $menuItemRepository): Response
|
||||
{
|
||||
$foodOrder = $orderItem->getFoodOrder();
|
||||
if ($foodOrder->isClosed()) {
|
||||
return $this->redirectToRoute('app_food_order_show', [
|
||||
'id' => $foodOrder->getId(),
|
||||
], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
$entityManager->remove($orderItem);
|
||||
$entityManager->flush();
|
||||
return $this->redirectToRoute('app_food_order_show', [
|
||||
'id' => $orderItem->getFoodOrder()
|
||||
->getId(),
|
||||
], Response::HTTP_SEE_OTHER);
|
||||
|
||||
$orderItem = new OrderItem;
|
||||
$username = $request->cookies->get('username', 'nobody');
|
||||
$orderItem->setCreatedBy($username);
|
||||
|
||||
$form = $this->createForm(OrderItemType::class, $orderItem);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$menuItem = $menuItemRepository->findOneBy([
|
||||
'name' => $orderItem->getName(),
|
||||
'foodVendor' => $foodOrder->getFoodVendor(),
|
||||
]);
|
||||
|
||||
if ($menuItem === null) {
|
||||
$menuItem = new MenuItem;
|
||||
$menuItem->setName($orderItem->getName());
|
||||
$menuItem->setFoodVendor($foodOrder->getFoodVendor());
|
||||
$entityManager->persist($menuItem);
|
||||
}
|
||||
|
||||
if ($menuItem->getAliasOf() !== null) {
|
||||
$menuItem = $menuItem->getAliasOf();
|
||||
$orderItem->setName($menuItem->getName());
|
||||
}
|
||||
|
||||
$orderItem->setMenuItem($menuItem);
|
||||
$orderItem->setFoodOrder($foodOrder);
|
||||
$entityManager->persist($orderItem);
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_food_order_show', [
|
||||
'id' => $foodOrder->getId(),
|
||||
], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
$menuItems = $menuItemRepository->findBy([
|
||||
'foodVendor' => $foodOrder->getFoodVendor(),
|
||||
'deletedAt' => null,
|
||||
]);
|
||||
|
||||
return $this->render('order_item/new.html.twig', [
|
||||
'order_item' => $orderItem,
|
||||
'food_order' => $foodOrder,
|
||||
'form' => $form,
|
||||
'menuItems' => $menuItems,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,29 +16,6 @@ final class AppFixtures extends Fixture
|
|||
{
|
||||
private ObjectManager $manager;
|
||||
|
||||
#[Override]
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
$this->manager = $manager;
|
||||
$vendorA = $this->createVendor('Vendor A');
|
||||
$this->addMenuItemsToVendor($vendorA);
|
||||
|
||||
$vendorB = $this->createVendor('Vendor B');
|
||||
$this->addMenuItemsToVendor($vendorB);
|
||||
}
|
||||
|
||||
public function createVendor(string $name): FoodVendor
|
||||
{
|
||||
$vendorA = new FoodVendor;
|
||||
$vendorA->setName($name);
|
||||
$vendorA->setMenuLink('https://vendora.com');
|
||||
$vendorA->setPhone('1234567890');
|
||||
|
||||
$this->manager->persist($vendorA);
|
||||
$this->manager->flush();
|
||||
return $vendorA;
|
||||
}
|
||||
|
||||
public function addMenuItemsToVendor(FoodVendor $vendor): void
|
||||
{
|
||||
$menuItems = [];
|
||||
|
@ -63,4 +40,27 @@ final class AppFixtures extends Fixture
|
|||
$this->manager->persist($orderItem);
|
||||
}
|
||||
}
|
||||
|
||||
public function createVendor(string $name): FoodVendor
|
||||
{
|
||||
$vendorA = new FoodVendor;
|
||||
$vendorA->setName($name);
|
||||
$vendorA->setMenuLink('https://vendora.com');
|
||||
$vendorA->setPhone('1234567890');
|
||||
|
||||
$this->manager->persist($vendorA);
|
||||
$this->manager->flush();
|
||||
return $vendorA;
|
||||
}
|
||||
|
||||
#[Override]
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
$this->manager = $manager;
|
||||
$vendorA = $this->createVendor('Vendor A');
|
||||
$this->addMenuItemsToVendor($vendorA);
|
||||
|
||||
$vendorB = $this->createVendor('Vendor B');
|
||||
$this->addMenuItemsToVendor($vendorB);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,32 +47,32 @@ use function iterator_to_array;
|
|||
#[ORM\Entity(repositoryClass: FoodOrderRepository::class)]
|
||||
class FoodOrder
|
||||
{
|
||||
#[ORM\Column(nullable: true)]
|
||||
#[Groups(['food_order:read'])]
|
||||
#[ORM\Column(nullable: true)]
|
||||
private DateTimeImmutable|null $closedAt = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'foodOrders')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[Groups(['food_order:read'])]
|
||||
#[ORM\Column(length: 255, options: [
|
||||
'default' => 'nobody',
|
||||
])]
|
||||
private string|null $createdBy = 'nobody';
|
||||
|
||||
#[Groups(['food_order:read', 'food_order:latest'])]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[ORM\ManyToOne(inversedBy: 'foodOrders')]
|
||||
private FoodVendor|null $foodVendor = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, OrderItem>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: OrderItem::class, mappedBy: 'foodOrder', orphanRemoval: true)]
|
||||
#[Groups(['food_order:read', 'food_order:latest'])]
|
||||
#[ORM\OneToMany(targetEntity: OrderItem::class, mappedBy: 'foodOrder', orphanRemoval: true)]
|
||||
private Collection $orderItems;
|
||||
|
||||
#[ORM\Column(length: 255, options: [
|
||||
'default' => 'nobody',
|
||||
])]
|
||||
#[Groups(['food_order:read'])]
|
||||
private string|null $createdBy = 'nobody';
|
||||
|
||||
public function __construct(
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(type: UlidType::NAME, unique: true)]
|
||||
#[Groups(['food_order:read'])]
|
||||
#[ORM\Column(type: UlidType::NAME, unique: true)]
|
||||
#[ORM\Id]
|
||||
private Ulid|null $id = new Ulid
|
||||
) {
|
||||
$this->id ??= new Ulid;
|
||||
|
@ -80,9 +80,24 @@ class FoodOrder
|
|||
$this->open();
|
||||
}
|
||||
|
||||
public function getId(): Ulid|null
|
||||
public function addOrderItem(OrderItem $orderItem): static
|
||||
{
|
||||
return $this->id;
|
||||
if (! $this->orderItems->contains($orderItem)) {
|
||||
$this->orderItems->add($orderItem);
|
||||
$orderItem->setFoodOrder($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function close(): static
|
||||
{
|
||||
return $this->setClosedAt(new DateTimeImmutable);
|
||||
}
|
||||
|
||||
public function getClosedAt(): DateTimeImmutable|null
|
||||
{
|
||||
return $this->closedAt;
|
||||
}
|
||||
|
||||
#[Groups(['food_order:read'])]
|
||||
|
@ -91,35 +106,9 @@ class FoodOrder
|
|||
return $this->id->getDateTime();
|
||||
}
|
||||
|
||||
public function getClosedAt(): DateTimeImmutable|null
|
||||
public function getCreatedBy(): string|null
|
||||
{
|
||||
return $this->closedAt;
|
||||
}
|
||||
|
||||
public function setClosedAt(DateTimeImmutable|null $closedAt = null): static
|
||||
{
|
||||
$this->closedAt = $closedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isClosed(): bool
|
||||
{
|
||||
if (! $this->closedAt instanceof DateTimeImmutable) {
|
||||
return false;
|
||||
}
|
||||
return $this->closedAt < new DateTimeImmutable;
|
||||
}
|
||||
|
||||
public function close(): static
|
||||
{
|
||||
return $this->setClosedAt(new DateTimeImmutable);
|
||||
}
|
||||
|
||||
public function open(): static
|
||||
{
|
||||
$this->closedAt = (new DateTimeImmutable)->add(new DateInterval('PT1H'));
|
||||
return $this;
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
||||
public function getFoodVendor(): FoodVendor|null
|
||||
|
@ -127,11 +116,9 @@ class FoodOrder
|
|||
return $this->foodVendor;
|
||||
}
|
||||
|
||||
public function setFoodVendor(FoodVendor|null $foodVendor): static
|
||||
public function getId(): Ulid|null
|
||||
{
|
||||
$this->foodVendor = $foodVendor;
|
||||
|
||||
return $this;
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -159,13 +146,17 @@ class FoodOrder
|
|||
);
|
||||
}
|
||||
|
||||
public function addOrderItem(OrderItem $orderItem): static
|
||||
public function isClosed(): bool
|
||||
{
|
||||
if (! $this->orderItems->contains($orderItem)) {
|
||||
$this->orderItems->add($orderItem);
|
||||
$orderItem->setFoodOrder($this);
|
||||
if (! $this->closedAt instanceof DateTimeImmutable) {
|
||||
return false;
|
||||
}
|
||||
return $this->closedAt < new DateTimeImmutable;
|
||||
}
|
||||
|
||||
public function open(): static
|
||||
{
|
||||
$this->closedAt = (new DateTimeImmutable)->add(new DateInterval('PT1H'));
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -179,9 +170,11 @@ class FoodOrder
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getCreatedBy(): string|null
|
||||
public function setClosedAt(DateTimeImmutable|null $closedAt = null): static
|
||||
{
|
||||
return $this->createdBy;
|
||||
$this->closedAt = $closedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCreatedBy(string $createdBy): static
|
||||
|
@ -190,4 +183,11 @@ class FoodOrder
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setFoodVendor(FoodVendor|null $foodVendor): static
|
||||
{
|
||||
$this->foodVendor = $foodVendor;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,19 +16,17 @@ use Symfony\Component\Validator\Constraints\Length;
|
|||
|
||||
use function mb_strlen;
|
||||
|
||||
#[ORM\Entity(repositoryClass: FoodVendorRepository::class)]
|
||||
#[ApiResource]
|
||||
#[ORM\Entity(repositoryClass: FoodVendorRepository::class)]
|
||||
class FoodVendor
|
||||
{
|
||||
#[ORM\Column(length: 50)]
|
||||
/**
|
||||
* String of emojis (max 30 characters)
|
||||
*/
|
||||
#[Groups(['food_order:latest', 'food_vendor:read'])]
|
||||
private string|null $name = null;
|
||||
|
||||
#[ORM\Column(length: 50, nullable: true, options: [
|
||||
'default' => '',
|
||||
])]
|
||||
#[Groups(['food_order:latest', 'food_vendor:read'])]
|
||||
private string|null $phone = null;
|
||||
#[Length(max: 10)]
|
||||
#[ORM\Column(length: 30, nullable: true)]
|
||||
private string|null $emojis = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, FoodOrder>
|
||||
|
@ -42,24 +40,26 @@ class FoodVendor
|
|||
#[ORM\OneToMany(targetEntity: MenuItem::class, mappedBy: 'foodVendor', orphanRemoval: true)]
|
||||
private Collection $menuItems;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
#[Groups(['food_order:latest'])]
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private string|null $menuLink = null;
|
||||
|
||||
/**
|
||||
* String of emojis (max 30 characters)
|
||||
*/
|
||||
#[ORM\Column(length: 30, nullable: true)]
|
||||
#[Groups(['food_order:latest', 'food_vendor:read'])]
|
||||
#[Length(max: 10)]
|
||||
private string|null $emojis = null;
|
||||
#[ORM\Column(length: 50)]
|
||||
private string|null $name = null;
|
||||
|
||||
#[Groups(['food_order:latest', 'food_vendor:read'])]
|
||||
#[ORM\Column(length: 50, nullable: true, options: [
|
||||
'default' => '',
|
||||
])]
|
||||
private string|null $phone = null;
|
||||
|
||||
public function __construct(
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[Groups(['food_order:latest'])]
|
||||
#[ORM\Column(type: UlidType::NAME, unique: true)]
|
||||
#[ORM\CustomIdGenerator(class: UlidGenerator::class)]
|
||||
#[Groups(['food_order:latest'])]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\Id]
|
||||
private Ulid|null $id = new Ulid
|
||||
) {
|
||||
$this->id ??= new Ulid;
|
||||
|
@ -67,31 +67,6 @@ class FoodVendor
|
|||
$this->menuItems = new ArrayCollection;
|
||||
}
|
||||
|
||||
public function getId(): Ulid|null
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): string|null
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, FoodOrder>
|
||||
*/
|
||||
public function getFoodOrders(): Collection
|
||||
{
|
||||
return $this->foodOrders;
|
||||
}
|
||||
|
||||
public function addFoodOrder(FoodOrder $foodOrder): static
|
||||
{
|
||||
if (! $this->foodOrders->contains($foodOrder)) {
|
||||
|
@ -102,16 +77,34 @@ class FoodVendor
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function removeFoodOrder(FoodOrder $foodOrder): static
|
||||
public function addMenuItem(MenuItem $menuItem): static
|
||||
{
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($this->foodOrders->removeElement($foodOrder)) {
|
||||
$foodOrder->setFoodVendor(null);
|
||||
if (! $this->menuItems->contains($menuItem)) {
|
||||
$this->menuItems->add($menuItem);
|
||||
$menuItem->setFoodVendor($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEmojis(): string|null
|
||||
{
|
||||
return $this->emojis;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, FoodOrder>
|
||||
*/
|
||||
public function getFoodOrders(): Collection
|
||||
{
|
||||
return $this->foodOrders;
|
||||
}
|
||||
|
||||
public function getId(): Ulid|null
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, MenuItem>
|
||||
*/
|
||||
|
@ -125,11 +118,26 @@ class FoodVendor
|
|||
);
|
||||
}
|
||||
|
||||
public function addMenuItem(MenuItem $menuItem): static
|
||||
public function getMenuLink(): string|null
|
||||
{
|
||||
if (! $this->menuItems->contains($menuItem)) {
|
||||
$this->menuItems->add($menuItem);
|
||||
$menuItem->setFoodVendor($this);
|
||||
return $this->menuLink;
|
||||
}
|
||||
|
||||
public function getName(): string|null
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getPhone(): string|null
|
||||
{
|
||||
return $this->phone;
|
||||
}
|
||||
|
||||
public function removeFoodOrder(FoodOrder $foodOrder): static
|
||||
{
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($this->foodOrders->removeElement($foodOrder)) {
|
||||
$foodOrder->setFoodVendor(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
@ -145,34 +153,6 @@ class FoodVendor
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getMenuLink(): string|null
|
||||
{
|
||||
return $this->menuLink;
|
||||
}
|
||||
|
||||
public function setMenuLink(string|null $menuLink): static
|
||||
{
|
||||
$this->menuLink = $menuLink;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPhone(): string|null
|
||||
{
|
||||
return $this->phone;
|
||||
}
|
||||
|
||||
public function setPhone(string|null $phone): static
|
||||
{
|
||||
$this->phone = $phone;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEmojis(): string|null
|
||||
{
|
||||
return $this->emojis;
|
||||
}
|
||||
|
||||
public function setEmojis(string|null $emojis): static
|
||||
{
|
||||
if ($emojis !== null && mb_strlen($emojis) > 30) {
|
||||
|
@ -182,4 +162,24 @@ class FoodVendor
|
|||
$this->emojis = $emojis;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setMenuLink(string|null $menuLink): static
|
||||
{
|
||||
$this->menuLink = $menuLink;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setName(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPhone(string|null $phone): static
|
||||
{
|
||||
$this->phone = $phone;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,108 +16,36 @@ use Symfony\Component\Uid\Ulid;
|
|||
#[ORM\Entity(repositoryClass: MenuItemRepository::class)]
|
||||
class MenuItem
|
||||
{
|
||||
#[ORM\Column(length: 255)]
|
||||
private string|null $name = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'menuItems')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private FoodVendor|null $foodVendor = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private DateTimeImmutable|null $deletedAt = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'aliases')]
|
||||
private self|null $aliasOf = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, self>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: self::class, mappedBy: 'aliasOf')]
|
||||
private Collection $aliases;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'aliases')]
|
||||
private self|null $aliasOf = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private DateTimeImmutable|null $deletedAt = null;
|
||||
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[ORM\ManyToOne(inversedBy: 'menuItems')]
|
||||
private FoodVendor|null $foodVendor = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private string|null $name = null;
|
||||
|
||||
public function __construct(
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\Column(type: UlidType::NAME, unique: true)]
|
||||
#[ORM\CustomIdGenerator(class: UlidGenerator::class)]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\Id]
|
||||
private Ulid|null $id = new Ulid
|
||||
) {
|
||||
$this->id ??= new Ulid;
|
||||
$this->aliases = new ArrayCollection;
|
||||
}
|
||||
|
||||
public function getId(): Ulid|null
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): string|null
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFoodVendor(): FoodVendor|null
|
||||
{
|
||||
return $this->foodVendor;
|
||||
}
|
||||
|
||||
public function setFoodVendor(FoodVendor|null $foodVendor): static
|
||||
{
|
||||
$this->foodVendor = $foodVendor;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isDeleted(): bool
|
||||
{
|
||||
return $this->getDeletedAt() instanceof DateTimeImmutable;
|
||||
}
|
||||
|
||||
public function delete(): static
|
||||
{
|
||||
$this->setDeletedAt(new DateTimeImmutable);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDeletedAt(): DateTimeImmutable|null
|
||||
{
|
||||
return $this->deletedAt;
|
||||
}
|
||||
|
||||
public function setDeletedAt(DateTimeImmutable|null $deletedAt = new DateTimeImmutable): static
|
||||
{
|
||||
$this->deletedAt = $deletedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAliasOf(): self|null
|
||||
{
|
||||
return $this->aliasOf;
|
||||
}
|
||||
|
||||
public function setAliasOf(self|null $aliasOf): static
|
||||
{
|
||||
$this->aliasOf = $aliasOf;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, self>
|
||||
*/
|
||||
public function getAliases(): Collection
|
||||
{
|
||||
return $this->aliases;
|
||||
}
|
||||
|
||||
public function addAlias(self $alias): static
|
||||
{
|
||||
if (! $this->aliases->contains($alias)) {
|
||||
|
@ -128,6 +56,50 @@ class MenuItem
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function delete(): static
|
||||
{
|
||||
$this->setDeletedAt(new DateTimeImmutable);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, self>
|
||||
*/
|
||||
public function getAliases(): Collection
|
||||
{
|
||||
return $this->aliases;
|
||||
}
|
||||
|
||||
public function getAliasOf(): self|null
|
||||
{
|
||||
return $this->aliasOf;
|
||||
}
|
||||
|
||||
public function getDeletedAt(): DateTimeImmutable|null
|
||||
{
|
||||
return $this->deletedAt;
|
||||
}
|
||||
|
||||
public function getFoodVendor(): FoodVendor|null
|
||||
{
|
||||
return $this->foodVendor;
|
||||
}
|
||||
|
||||
public function getId(): Ulid|null
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): string|null
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function isDeleted(): bool
|
||||
{
|
||||
return $this->getDeletedAt() instanceof DateTimeImmutable;
|
||||
}
|
||||
|
||||
public function removeAlias(self $alias): static
|
||||
{
|
||||
// set the owning side to null (unless already changed)
|
||||
|
@ -137,4 +109,32 @@ class MenuItem
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setAliasOf(self|null $aliasOf): static
|
||||
{
|
||||
$this->aliasOf = $aliasOf;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setDeletedAt(DateTimeImmutable|null $deletedAt = new DateTimeImmutable): static
|
||||
{
|
||||
$this->deletedAt = $deletedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setFoodVendor(FoodVendor|null $foodVendor): static
|
||||
{
|
||||
$this->foodVendor = $foodVendor;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setName(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,62 +14,77 @@ use Symfony\Component\Uid\Ulid;
|
|||
#[ORM\Entity(repositoryClass: OrderItemRepository::class)]
|
||||
class OrderItem
|
||||
{
|
||||
#[ORM\Column(length: 255)]
|
||||
#[Groups(['food_order:latest'])]
|
||||
private string|null $name = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
#[Groups(['food_order:latest'])]
|
||||
private string|null $extras = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'orderItems')]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
private FoodOrder|null $foodOrder = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[Groups(['food_order:latest'])]
|
||||
private MenuItem|null $menuItem = null;
|
||||
|
||||
#[ORM\Column(length: 255, options: [
|
||||
'default' => 'nobody',
|
||||
])]
|
||||
#[Groups(['food_order:latest'])]
|
||||
private string|null $createdBy = 'nobody';
|
||||
|
||||
#[Groups(['food_order:latest'])]
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private string|null $extras = null;
|
||||
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
#[ORM\ManyToOne(inversedBy: 'orderItems')]
|
||||
private FoodOrder|null $foodOrder = null;
|
||||
|
||||
#[Groups(['food_order:latest'])]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[ORM\ManyToOne]
|
||||
private MenuItem|null $menuItem = null;
|
||||
|
||||
#[Groups(['food_order:latest'])]
|
||||
#[ORM\Column(length: 255)]
|
||||
private string|null $name = null;
|
||||
|
||||
public function __construct(
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[Groups(['food_order:latest'])]
|
||||
#[ORM\Column(type: UlidType::NAME, unique: true)]
|
||||
#[ORM\CustomIdGenerator(class: UlidGenerator::class)]
|
||||
#[Groups(['food_order:latest'])]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\Id]
|
||||
private Ulid|null $id = new Ulid
|
||||
) {
|
||||
$this->id ??= new Ulid;
|
||||
}
|
||||
|
||||
public function getCreatedBy(): string|null
|
||||
{
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
||||
public function getExtras(): string|null
|
||||
{
|
||||
return $this->extras;
|
||||
}
|
||||
|
||||
public function getFoodOrder(): FoodOrder|null
|
||||
{
|
||||
return $this->foodOrder;
|
||||
}
|
||||
|
||||
public function getId(): Ulid|null
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getMenuItem(): MenuItem|null
|
||||
{
|
||||
return $this->menuItem;
|
||||
}
|
||||
|
||||
public function getName(): string|null
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): static
|
||||
public function setCreatedBy(string $createdBy): static
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->createdBy = $createdBy;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getExtras(): string|null
|
||||
{
|
||||
return $this->extras;
|
||||
}
|
||||
|
||||
public function setExtras(string|null $extras): static
|
||||
{
|
||||
$this->extras = $extras;
|
||||
|
@ -77,11 +92,6 @@ class OrderItem
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getFoodOrder(): FoodOrder|null
|
||||
{
|
||||
return $this->foodOrder;
|
||||
}
|
||||
|
||||
public function setFoodOrder(FoodOrder|null $foodOrder): static
|
||||
{
|
||||
$this->foodOrder = $foodOrder;
|
||||
|
@ -89,11 +99,6 @@ class OrderItem
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getMenuItem(): MenuItem|null
|
||||
{
|
||||
return $this->menuItem;
|
||||
}
|
||||
|
||||
public function setMenuItem(MenuItem|null $menuItem): static
|
||||
{
|
||||
$this->menuItem = $menuItem;
|
||||
|
@ -102,14 +107,9 @@ class OrderItem
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getCreatedBy(): string|null
|
||||
public function setName(string $name): static
|
||||
{
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
||||
public function setCreatedBy(string $createdBy): static
|
||||
{
|
||||
$this->createdBy = $createdBy;
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
|
@ -19,12 +19,6 @@ final class FoodOrderRepository extends ServiceEntityRepository
|
|||
parent::__construct($registry, FoodOrder::class);
|
||||
}
|
||||
|
||||
public function save(): void
|
||||
{
|
||||
$this->getEntityManager()
|
||||
->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FoodOrder[]
|
||||
*/
|
||||
|
@ -48,6 +42,15 @@ final class FoodOrderRepository extends ServiceEntityRepository
|
|||
->getValues();
|
||||
}
|
||||
|
||||
public function findLatestOrder(): FoodOrder|null
|
||||
{
|
||||
return $this->createQueryBuilder('alias')
|
||||
->orderBy('alias.id', 'DESC')
|
||||
->setMaxResults(1)
|
||||
->getQuery()
|
||||
->getOneOrNullResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FoodOrder[]
|
||||
*/
|
||||
|
@ -63,12 +66,9 @@ final class FoodOrderRepository extends ServiceEntityRepository
|
|||
->getResult();
|
||||
}
|
||||
|
||||
public function findLatestOrder(): FoodOrder|null
|
||||
public function save(): void
|
||||
{
|
||||
return $this->createQueryBuilder('alias')
|
||||
->orderBy('alias.id', 'DESC')
|
||||
->setMaxResults(1)
|
||||
->getQuery()
|
||||
->getOneOrNullResult();
|
||||
$this->getEntityManager()
|
||||
->flush();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,10 +18,10 @@ use function str_contains;
|
|||
abstract class DbWebTest extends WebTestCase
|
||||
{
|
||||
protected KernelBrowser $client;
|
||||
protected EntityManagerInterface $manager;
|
||||
protected EntityRepository $repository;
|
||||
protected string $entityClass = '';
|
||||
protected EntityManagerInterface $manager;
|
||||
protected string $path = '';
|
||||
protected EntityRepository $repository;
|
||||
|
||||
#[Override]
|
||||
protected function setUp(): void
|
||||
|
@ -35,13 +35,6 @@ abstract class DbWebTest extends WebTestCase
|
|||
$schemaTool->updateSchema($metadata);
|
||||
}
|
||||
|
||||
protected function generateOldUlid(int $daysToSubtract = 10): Ulid
|
||||
{
|
||||
$date = (new DateTimeImmutable)->sub(new DateInterval('P' . $daysToSubtract . 'D'));
|
||||
$ulidString = Ulid::generate($date);
|
||||
return Ulid::fromString($ulidString);
|
||||
}
|
||||
|
||||
protected function assertElementContainsCount(Crawler $crawler, string $element, int $count, string $text): void
|
||||
{
|
||||
$this->assertCount(
|
||||
|
@ -53,6 +46,13 @@ abstract class DbWebTest extends WebTestCase
|
|||
);
|
||||
}
|
||||
|
||||
protected function generateOldUlid(int $daysToSubtract = 10): Ulid
|
||||
{
|
||||
$date = (new DateTimeImmutable)->sub(new DateInterval('P' . $daysToSubtract . 'D'));
|
||||
$ulidString = Ulid::generate($date);
|
||||
return Ulid::fromString($ulidString);
|
||||
}
|
||||
|
||||
protected function setEntityClass(string $entityClass): void
|
||||
{
|
||||
$this->entityClass = $entityClass;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue