@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | class ProductRepository extends ServiceEntityRepository |
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - private $inventory_exclude_types = ['custom', 'component', 'manufactured']; |
|
| 22 | + private $inventory_exclude_types = [ 'custom', 'component', 'manufactured' ]; |
|
| 23 | 23 | |
| 24 | 24 | public function __construct( |
| 25 | 25 | private PeopleService $peopleService, |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | $result = $stmt->executeQuery(); |
| 138 | 138 | |
| 139 | 139 | $data = $result->fetchAssociative(); |
| 140 | - return $data ? $this->getEntityManager()->getRepository(Product::class)->find($data['id']) : null; |
|
| 140 | + return $data ? $this->getEntityManager()->getRepository(Product::class)->find($data[ 'id' ]) : null; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | } |
@@ -26,25 +26,25 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | ) {} |
| 28 | 28 | |
| 29 | - #[Route('/products/purchasing-suggestion', name: 'purchasing_suggestion', methods: ['GET'])] |
|
| 30 | - #[Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')")] |
|
| 29 | + #[Route('/products/purchasing-suggestion', name: 'purchasing_suggestion', methods: [ 'GET' ]) ] |
|
| 30 | + #[Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')") ] |
|
| 31 | 31 | public function getPurchasingSuggestion(Request $request): JsonResponse |
| 32 | 32 | { |
| 33 | - $company = $this->manager->getRepository(People::class)->find($request->get('company')); |
|
| 33 | + $company = $this->manager->getRepository(People::class)->find($request->get('company')); |
|
| 34 | 34 | $data = $this->productService->getPurchasingSuggestion($company); |
| 35 | 35 | return new JsonResponse($data); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - #[Route('/products/purchasing-suggestion/print', name: 'purchasing_suggestion_print', methods: ['POST'])] |
|
| 39 | - #[Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')")] |
|
| 38 | + #[Route('/products/purchasing-suggestion/print', name: 'purchasing_suggestion_print', methods: [ 'POST' ]) ] |
|
| 39 | + #[Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')") ] |
|
| 40 | 40 | public function printPurchasingSuggestion(Request $request): JsonResponse |
| 41 | 41 | { |
| 42 | 42 | try { |
| 43 | 43 | $data = json_decode($request->getContent(), true); |
| 44 | 44 | $device = $this->manager->getRepository(Device::class)->findOneBy([ |
| 45 | - 'device' => $data['device'] |
|
| 45 | + 'device' => $data[ 'device' ] |
|
| 46 | 46 | ]); |
| 47 | - $company = $this->manager->getRepository(People::class)->find($data['people']); |
|
| 47 | + $company = $this->manager->getRepository(People::class)->find($data[ 'people' ]); |
|
| 48 | 48 | $printData = $this->productService->purchasingSuggestionPrintData($company, $device); |
| 49 | 49 | |
| 50 | 50 | return new JsonResponse($this->hydratorService->item(Spool::class, $printData->getId(), "spool_item:read"), Response::HTTP_OK); |
@@ -53,26 +53,26 @@ discard block |
||
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - #[Route('/products/inventory', name: 'products_inventory', methods: ['GET'])] |
|
| 57 | - #[Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')")] |
|
| 56 | + #[Route('/products/inventory', name: 'products_inventory', methods: [ 'GET' ]) ] |
|
| 57 | + #[Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')") ] |
|
| 58 | 58 | public function getProductsInventory(Request $request): JsonResponse |
| 59 | 59 | { |
| 60 | - $company = $this->manager->getRepository(People::class)->find($request->get('company')); |
|
| 60 | + $company = $this->manager->getRepository(People::class)->find($request->get('company')); |
|
| 61 | 61 | $data = $this->productService->getProductsInventory($company); |
| 62 | 62 | return new JsonResponse($data); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - #[Route('/products/inventory/print', name: 'products_inventory_print', methods: ['POST'])] |
|
| 66 | - #[Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')")] |
|
| 65 | + #[Route('/products/inventory/print', name: 'products_inventory_print', methods: [ 'POST' ]) ] |
|
| 66 | + #[Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')") ] |
|
| 67 | 67 | public function print(Request $request): JsonResponse |
| 68 | 68 | { |
| 69 | 69 | try { |
| 70 | 70 | $data = json_decode($request->getContent(), true); |
| 71 | 71 | $device = $this->manager->getRepository(Device::class)->findOneBy([ |
| 72 | - 'device' => $data['device'] |
|
| 72 | + 'device' => $data[ 'device' ] |
|
| 73 | 73 | ]); |
| 74 | 74 | |
| 75 | - $company = $this->manager->getRepository(People::class)->find($data['people']); |
|
| 75 | + $company = $this->manager->getRepository(People::class)->find($data[ 'people' ]); |
|
| 76 | 76 | $printData = $this->productService->productsInventoryPrintData($company, $device); |
| 77 | 77 | return new JsonResponse($this->hydratorService->item(Spool::class, $printData->getId(), "spool_item:read"), Response::HTTP_OK); |
| 78 | 78 | } catch (Exception $e) { |
@@ -80,22 +80,22 @@ discard block |
||
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - #[Route('/products/sku', name: 'product_by_sku', methods: ['POST'])] |
|
| 84 | - #[Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')")] |
|
| 83 | + #[Route('/products/sku', name: 'product_by_sku', methods: [ 'POST' ]) ] |
|
| 84 | + #[Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')") ] |
|
| 85 | 85 | public function getProductBySku(Request $request): JsonResponse |
| 86 | 86 | { |
| 87 | 87 | try { |
| 88 | 88 | $data = json_decode($request->getContent(), true); |
| 89 | 89 | |
| 90 | - if (!isset($data['sku'], $data['people'])) { |
|
| 91 | - return new JsonResponse(['error' => 'Parâmetros obrigatórios: sku e people'], Response::HTTP_BAD_REQUEST); |
|
| 90 | + if (!isset($data[ 'sku' ], $data[ 'people' ])) { |
|
| 91 | + return new JsonResponse([ 'error' => 'Parâmetros obrigatórios: sku e people' ], Response::HTTP_BAD_REQUEST); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - $sku = (int) ltrim($data['sku'], '0'); |
|
| 95 | - $company = $this->manager->getRepository(People::class)->find($data['people']); |
|
| 94 | + $sku = (int) ltrim($data[ 'sku' ], '0'); |
|
| 95 | + $company = $this->manager->getRepository(People::class)->find($data[ 'people' ]); |
|
| 96 | 96 | |
| 97 | 97 | if (!$company) { |
| 98 | - return new JsonResponse(['error' => 'Empresa não encontrada'], Response::HTTP_NOT_FOUND); |
|
| 98 | + return new JsonResponse([ 'error' => 'Empresa não encontrada' ], Response::HTTP_NOT_FOUND); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | $product = $this->manager |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | ->findProductBySkuAsInteger($sku, $company); |
| 104 | 104 | |
| 105 | 105 | if (!$product) { |
| 106 | - return new JsonResponse(['error' => 'Produto não encontrado'], Response::HTTP_NOT_FOUND); |
|
| 106 | + return new JsonResponse([ 'error' => 'Produto não encontrado' ], Response::HTTP_NOT_FOUND); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | return new JsonResponse( |
@@ -111,14 +111,14 @@ discard block |
||
| 111 | 111 | Response::HTTP_OK |
| 112 | 112 | ); |
| 113 | 113 | } catch (\Exception $e) { |
| 114 | - return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_INTERNAL_SERVER_ERROR); |
|
| 114 | + return new JsonResponse([ 'error' => $e->getMessage() ], Response::HTTP_INTERNAL_SERVER_ERROR); |
|
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - #[Route('/teste', name: 'teste', methods: ['GET'])] |
|
| 118 | + #[Route('/teste', name: 'teste', methods: [ 'GET' ]) ] |
|
| 119 | 119 | public function teste(): JsonResponse |
| 120 | 120 | { |
| 121 | - return new JsonResponse(['message' => 'rota funcionando']); |
|
| 121 | + return new JsonResponse([ 'message' => 'rota funcionando' ]); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | } |