denyAccessUnlessGranted('jo_in.list', null, 'No access.'); $params = $jo_handler->getJobOrders($req); $job_orders = $params['job_orders']; $has_more_pages = $params['has_more_pages']; // response return $this->json([ 'success' => true, 'results' => $job_orders, 'pagination' => [ 'more' => $has_more_pages ] ]); } /** * @Menu(selected="jo_in") */ public function incomingForm(JobOrderHandlerInterface $jo_handler, GISManagerInterface $gis) { $this->denyAccessUnlessGranted('jo_in.list', null, 'No access.'); $params = $jo_handler->initializeIncomingForm(); $params['submit_url'] = $this->generateUrl('jo_in_submit'); $params['return_url'] = $this->generateUrl('jo_in'); $params['map_js_file'] = $gis->getJSJOFile(); $template = $params['template']; // response return $this->render($template, $params); } /** * @Menu(selected="jo_in") */ public function openEditForm($id, JobOrderHandlerInterface $jo_handler, GISManagerInterface $gis) { $this->denyAccessUnlessGranted('jo_open.edit', null, 'No access.'); $params = $jo_handler->initializeOpenEditForm($id); $params['submit_url'] = $this->generateUrl('jo_open_edit_submit', ['id' => $id]); $params['return_url'] = $this->generateUrl('jo_open'); $params['map_js_file'] = $gis->getJSJOFile(); $template = $params['template']; // response return $this->render($template, $params); } public function openEditSubmit(Request $req, JobOrderHandlerInterface $jo_handler, $id) { $this->denyAccessUnlessGranted('jo_open.edit', null, 'No access.'); $error_array = []; $error_array = $jo_handler->generateJobOrder($req, $id); // check if any errors were found if (!empty($error_array)) { // return validation failure response return $this->json([ 'success' => false, 'errors' => $error_array ], 422); } // return successful response return $this->json([ 'success' => 'Changes have been saved!' ]); } /** * @Menu(selected="jo_in") */ public function incomingVehicleForm($cvid, JobOrderHandlerInterface $jo_handler) { $this->denyAccessUnlessGranted('jo_in.list', null, 'No access.'); try { $params = $jo_handler->initializeIncomingVehicleForm($cvid); } catch (NotFoundHttpException $e) { throw $this->createNotFoundException($e->getMessage()); } $params['submit_url'] = $this->generateUrl('jo_in_submit'); $params['return_url'] = $this->generateUrl('jo_in'); $template = $params['template']; // response return $this->render($template, $params); } public function incomingSubmit(Request $req, JobOrderHandlerInterface $jo_handler) { $this->denyAccessUnlessGranted('jo_in.list', null, 'No access.'); // initialize error list $error_array = []; $id = -1; $error_array = $jo_handler->generateJobOrder($req, $id); // check if any errors were found if (!empty($error_array)) { // return validation failure response return $this->json([ 'success' => false, 'errors' => $error_array ], 422); } // return successful response return $this->json([ 'success' => 'Changes have been saved!' ]); } /** * @Menu(selected="jo_proc") */ public function listProcessing(JobOrderHandlerInterface $jo_handler) { $this->denyAccessUnlessGranted('jo_proc.list', null, 'No access.'); $template = $jo_handler->getTwigTemplate('jo_list_processing'); $params['table_refresh_rate'] = $this->container->getParameter('job_order_refresh_interval'); return $this->render($template, $params); } /** * @Menu(selected="jo_assign") */ public function listAssigning(JobOrderHandlerInterface $jo_handler) { $this->denyAccessUnlessGranted('jo_assign.list', null, 'No access.'); $template = $jo_handler->getTwigTemplate('jo_list_assigning'); $params['table_refresh_rate'] = $this->container->getParameter('job_order_refresh_interval'); return $this->render($template, $params); } /** * @Menu(selected="jo_fulfill") */ public function listFulfillment(JobOrderHandlerInterface $jo_handler) { $this->denyAccessUnlessGranted('jo_fulfill.list', null, 'No access.'); $template = $jo_handler->getTwigTemplate('jo_list_fulfillment'); $params = $jo_handler->getOtherParameters(); $params['table_refresh_rate'] = $this->container->getParameter('job_order_refresh_interval'); return $this->render($template, $params); } /** * @Menu(selected="jo_open") */ public function listOpen(JobOrderHandlerInterface $jo_handler) { $this->denyAccessUnlessGranted('jo_open.list', null, 'No access.'); $template = $jo_handler->getTwigTemplate('jo_list_open'); $params = $jo_handler->getOtherParameters(); $params['table_refresh_rate'] = $this->container->getParameter('job_order_refresh_interval'); $params['statuses'] = JOStatus::getCollection(); return $this->render($template, $params); } /** * @Menu(selected="jo_all") */ public function listAll(JobOrderHandlerInterface $jo_handler) { $this->denyAccessUnlessGranted('jo_all.list', null, 'No access.'); $template = $jo_handler->getTwigTemplate('jo_list_all'); $params = $jo_handler->getOtherParameters(); $params['table_refresh_rate'] = $this->container->getParameter('job_order_refresh_interval'); return $this->render($template, $params); } /* public function listRows($tier) { // check which job order tier is being called for and confirm access $tier_params = $this->checkTier($tier); $params = $this->initParameters($tier_params['key']); $params['tier_name'] = $tier_params['name']; $params['rows_route'] = $tier_params['rows_route']; $params['table_refresh_rate'] = $this->container->getParameter('job_order_refresh_interval'); // response return $this->render('job-order/list.html.twig', $params); } */ public function getRows(Request $req, $tier, JobOrderHandlerInterface $jo_handler) { try { $params = $jo_handler->getRows($req, $tier); } catch (AccessDeniedHttpException $e) { throw $this->createAccessDeniedException($e->getMessage()); } $rows = $params['rows']; $meta = $params['meta']; $tier_params = $params['tier_params']; foreach ($rows as $key => $data) { // add crud urls $jo_id = $rows[$key]['id']; if ($tier == 'open') { $rows[$key]['meta']['reassign_hub_url'] = $this->generateUrl('jo_open_hub_form', ['id' => $jo_id]); $rows[$key]['meta']['reassign_rider_url'] = $this->generateUrl('jo_open_rider_form', ['id' => $jo_id]); $rows[$key]['meta']['edit_url'] = $this->generateUrl('jo_open_edit_form', ['id' => $jo_id]); $rows[$key]['meta']['onestep_edit_url'] = $this->generateUrl('jo_onestep_edit_form', ['id' => $jo_id]); } else { $rows[$key]['meta']['update_url'] = $this->generateUrl($tier_params['edit_route'], ['id' => $jo_id]); $rows[$key]['meta']['onestep_edit_url'] = $this->generateUrl('jo_onestep_edit_form', ['id' => $jo_id]); $rows[$key]['meta']['pdf_url'] = $this->generateUrl('jo_pdf_form', ['id' => $jo_id]); } if ($tier_params['unlock_route'] != '') $rows[$key]['meta']['unlock_url'] = $this->generateUrl($tier_params['unlock_route'], ['id' => $jo_id]); } // response return $this->json([ 'meta' => $meta, 'data' => $rows ]); } /** * @Menu(selected="jo_proc") */ public function processingForm(MapTools $map_tools, $id, JobOrderHandlerInterface $jo_handler, GISManagerInterface $gis) { $this->denyAccessUnlessGranted('jo_proc.list', null, 'No access.'); try { $params = $jo_handler->initializeProcessingForm($id, $map_tools); } catch (AccessDeniedHttpException $e) { throw $this->createAccessDeniedException($e->getMessage()); } catch (NotFoundHttpException $e) { throw $this->createNotFoundException($e->getMessage()); } $params['submit_url'] = $this->generateUrl('jo_proc_submit', ['id' => $id]); $params['return_url'] = $this->generateUrl('jo_proc'); $params['map_js_file'] = $gis->getJSJOFile(); $template = $params['template']; // response return $this->render($template, $params); } public function processingSubmit(Request $req, JobOrderHandlerInterface $jo_handler, MQTTClient $mclient, $id) { $this->denyAccessUnlessGranted('jo_proc.list', null, 'No access.'); // initialize error list $error_array = []; try { $error_array = $jo_handler->dispatchJobOrder($req, $id, $mclient); } catch (AccessDeniedHttpException $e) { throw $this->createAccessDeniedException($e->getMessage()); } catch (NotFoundHttpException $e) { throw $this->createNotFoundException($e->getMessage()); } // check if any errors were found if (!empty($error_array)) { // return validation failure response return $this->json([ 'success' => false, 'errors' => $error_array ], 422); } // return successful response return $this->json([ 'success' => 'Changes have been saved!' ]); } /** * @Menu(selected="jo_assign") */ public function assigningForm($id, JobOrderHandlerInterface $jo_handler, GISManagerInterface $gis) { $this->denyAccessUnlessGranted('jo_assign.list', null, 'No access.'); try { $params = $jo_handler->initializeAssignForm($id); } catch (AccessDeniedHttpException $e) { throw $this->createAccessDeniedException($e->getMessage()); } catch (NotFoundHttpException $e) { throw $this->createNotFoundException($e->getMessage()); } $params['submit_url'] = $this->generateUrl('jo_assign_submit', ['id' => $id]); $params['return_url'] = $this->generateUrl('jo_assign'); $params['map_js_file'] = $gis->getJSJOFile(); $template = $params['template']; // response return $this->render($template, $params); } public function assigningSubmit(Request $req, JobOrderHandlerInterface $jo_handler, MQTTCLient $mclient, APNSClient $aclient, $id) { $this->denyAccessUnlessGranted('jo_assign.list', null, 'No access.'); // initialize error list $error_array = []; try { $error_array = $jo_handler->assignJobOrder($req, $id, $mclient, $aclient); } catch (NotFoundHttpException $e) { throw $this->createNotFoundException($e->getMessage()); } // check if any errors were found if (!empty($error_array)) { // return validation failure response return $this->json([ 'success' => false, 'errors' => $error_array ], 422); } // return successful response return $this->json([ 'success' => 'Changes have been saved!' ]); } /** * @Menu(selected="jo_fulfill") */ public function fulfillmentForm(JobOrderHandlerInterface $jo_handler, $id, GISManagerInterface $gis) { $this->denyAccessUnlessGranted('jo_fulfill.list', null, 'No access.'); try { $params = $jo_handler->initializeFulfillmentForm($id); } catch (NotFoundHttpException $e) { throw $this->createNotFoundException($e->getMessage()); } $params['submit_url'] = $this->generateUrl('jo_fulfill_submit', ['id' => $id]); $params['return_url'] = $this->generateUrl('jo_fulfill'); $params['map_js_file'] = $gis->getJSJOFile(); $template = $params['template']; // response return $this->render($template, $params); } public function fulfillmentSubmit(Request $req, JobOrderHandlerInterface $jo_handler, MQTTClient $mclient, $id) { $this->denyAccessUnlessGranted('jo_fulfill.list', null, 'No access.'); // initialize error list $error_array = []; try { $error_array = $jo_handler->fulfillJobOrder($req, $id, $mclient); } catch (NotFoundHttpException $e) { throw $this->createNotFoundException($e->getMessage()); } // check if any errors were found if (!empty($error_array)) { // return validation failure response return $this->json([ 'success' => false, 'errors' => $error_array ], 422); } // return successful response return $this->json([ 'success' => 'Changes have been saved!' ]); } /** * @Menu(selected="jo_open") */ public function openHubForm(MapTools $map_tools, $id, JobOrderHandlerInterface $jo_handler, GISManagerInterface $gis) { $this->denyAccessUnlessGranted('jo_open.list', null, 'No access.'); try { $params = $jo_handler->initializeHubForm($id, $map_tools); } catch (NotFoundHttpException $e) { throw $this->createNotFoundException($e->getMessage()); } $params['submit_url'] = $this->generateUrl('jo_open_hub_submit', ['id' => $id]); $params['return_url'] = $this->generateUrl('jo_open'); $params['map_js_file'] = $gis->getJSJOFile(); $template = $params['template']; // response return $this->render($template, $params); } public function openHubSubmit(Request $req, JobOrderHandlerInterface $jo_handler, MQTTClient $mclient, $id) { $this->denyAccessUnlessGranted('jo_open.list', null, 'No access.'); // initialize error list $error_array = []; try { $error_array = $jo_handler->setHub($req, $id, $mclient); } catch (NotFoundHttpException $e) { throw $this->createNotFoundException($e->getMessage()); } // check if any errors were found if (!empty($error_array)) { // return validation failure response return $this->json([ 'success' => false, 'errors' => $error_array ], 422); } // return successful response return $this->json([ 'success' => 'Changes have been saved!' ]); } /** * @Menu(selected="jo_open") */ public function openRiderForm($id, JobOrderHandlerInterface $jo_handler, GISManagerInterface $gis) { $this->denyAccessUnlessGranted('jo_open.list', null, 'No access.'); try { $params = $jo_handler->initializeRiderForm($id); } catch (NotFoundHttpException $e) { throw $this->createNotFoundException($e->getMessage()); } $params['submit_url'] = $this->generateUrl('jo_open_rider_submit', ['id' => $id]); $params['return_url'] = $this->generateUrl('jo_open'); $params['map_js_file'] = $gis->getJSJOFile(); $template = $params['template']; // response return $this->render($template, $params); } public function openRiderSubmit(Request $req, JobOrderHandlerInterface $jo_handler, MQTTClient $mclient, $id) { $this->denyAccessUnlessGranted('jo_open.list', null, 'No access.'); // initialize error list $error_array = []; try { $error_array = $jo_handler->setRider($req, $id, $mclient); } catch (NotFoundHttpException $e) { throw $this->createNotFoundException($e->getMessage()); } // check if any errors were found if (!empty($error_array)) { // return validation failure response return $this->json([ 'success' => false, 'errors' => $error_array ], 422); } // return successful response return $this->json([ 'success' => 'Changes have been saved!' ]); } /** * @Menu(selected="jo_all") */ public function allForm($id, JobOrderHandlerInterface $jo_handler, GISManagerInterface $gis) { $this->denyAccessUnlessGranted('jo_all.list', null, 'No access.'); try { $params = $jo_handler->initializeAllForm($id); } catch (NotFoundHttpException $e) { throw $this->createNotFoundException($e->getMessage()); } $params['return_url'] = $this->generateUrl('jo_all'); $params['submit_url'] = ''; $params['map_js_file'] = $gis->getJSJOFile(); $template = $params['template']; // response return $this->render($template, $params); } public function pdfForm(Request $req, $id, JobOrderHandlerInterface $jo_handler) { $this->denyAccessUnlessGranted('jo_pdf.list', null, 'No access.'); try { $proj_path = $this->get('kernel')->getProjectDir(); $params = $jo_handler->generatePDFForm($req, $id, $proj_path); } catch (NotFoundHttpException $e) { throw $this->createNotFoundException($e->getMessage()); } $pdf = $params['obj']; $filename = $params['filename']; // return response return new Response($pdf->Output('I', $filename), 200, [ 'Content-Type' => 'application/pdf' ]); } public function cancelJobOrder(Request $req, JobOrderHandlerInterface $jo_handler, MQTTClient $mclient, $id) { $this->denyAccessUnlessGranted('joborder.cancel', null, 'No access.'); $cancel_reason = $req->request->get('cancel_reason'); if (empty($cancel_reason)) { // something happened return $this->json([ 'success' => false, 'error' => 'Reason for cancellation is required.' ], 422); } try { $jo_handler->cancelJobOrder($req, $id, $mclient); } catch (NotFoundHttpException $e) { throw $this->createNotFoundException($e->getMessage()); } // return successful response return $this->json([ 'success' => 'Job order has been cancelled!' ]); } public function generateInvoice(Request $req, InvoiceGeneratorInterface $ic) { // error_log('generating invoice...'); $error = false; $stype = $req->request->get('stype'); $items = $req->request->get('items'); $promo_id = $req->request->get('promo'); $cvid = $req->request->get('cvid'); $em = $this->getDoctrine()->getManager(); // get customer vehicle $cv = $em->getRepository(CustomerVehicle::class)->find($cvid); /* if ($cv == null) throw new \Exception('Could not get customer vehicle'); */ // instantiate invoice criteria $criteria = new InvoiceCriteria(); $criteria->setServiceType($stype) ->setCustomerVehicle($cv); /* // if it's a jumpstart or troubleshoot only, we know what to charge already if ($stype == ServiceType::JUMPSTART_TROUBLESHOOT) { $invoice = [ 'price' => 150.00, 'discount' => 0, 'trade_in' => 0, 'vat' => 0, 'total_price' => 150.00, 'items' => [] ]; $invoice['items'][] = [ 'title' => 'Troubleshooting fee', 'quantity' => 1, 'unit_price' => 150.00, 'amount' => 150.00 ]; return $this->json([ 'success' => true, 'invoice' => $invoice ]); } */ // TODO: this snippet should be in the invoice generator $error = $ic->validateDiscount($criteria, $promo_id); if (!$error) $error = $ic->invoiceBatteries($criteria, $items); if ($error) { // something happened return $this->json([ 'success' => false, 'error' => $error ], 422); } // generate the invoice $iobj = $ic->generateInvoice($criteria); // use invoice object values in a json friendly array $invoice = [ 'discount' => number_format($iobj->getDiscount(), 2), 'trade_in' => number_format($iobj->getTradeIn(), 2), // TODO: computations not done yet for this on invoice creator 'price' => number_format($iobj->getVATExclusivePrice(), 2), 'vat' => number_format($iobj->getVAT(), 2), 'total_price' => number_format($iobj->getTotalPrice(), 2), 'items' => [] ]; foreach ($iobj->getItems() as $item) { $invoice['items'][] = [ 'title' => $item->getTitle(), 'quantity' => number_format($item->getQuantity()), // TODO: quantities are always 1, hardcoded into InvoiceCreator. no way of accepting quantities on InvoiceCriteria 'unit_price' => number_format($item->getPrice(), 2), 'amount' => number_format($item->getPrice() * $item->getQuantity(), 2) // TODO: should this calculation should be a saved value on InvoiceItem instead? ]; } // return return $this->json([ 'success' => true, 'invoice' => $invoice ]); } public function unlockProcessor($id, JobOrderHandlerInterface $jo_handler) { $this->denyAccessUnlessGranted('jo_proc.unlock', null, 'No access.'); // call unlockProcessor in job order service $jo_handler->unlockProcessor($id); // redirect to list return $this->redirectToRoute('jo_proc'); } public function unlockAssignor($id, JobOrderHandlerInterface $jo_handler) { $this->denyAccessUnlessGranted('jo_assign.unlock', null, 'No access.'); // call unlockAssignor in job order service $jo_handler->unlockAssignor($id); // redirect to list return $this->redirectToRoute('jo_assign'); } public function rejectHubSubmit(Request $req, JobOrderHandlerInterface $jo_handler, $id) { $this->denyAccessUnlessGranted('jo_proc.list', null, 'No access.'); // initialize error list $error_array = []; try { $error_array = $jo_handler->rejectHub($req, $id); } catch (AccessDeniedHttpException $e) { throw $this->createAccessDeniedException($e->getMessage()); } catch (NotFoundHttpException $e) { throw $this->createNotFoundException($e->getMessage()); } // check if any errors were found if (!empty($error_array)) { // return validation failure response return $this->json([ 'success' => false, 'errors' => $error_array ], 422); } // return successful response return $this->json([ 'success' => 'Changes have been saved!', 'request' => $req->request->all() ]); } /** * @Menu(selected="jo_onestep_form") */ public function oneStepForm(EntityManagerInterface $em, JobOrderHandlerInterface $jo_handler, GISManagerInterface $gis) { $this->denyAccessUnlessGranted('jo_onestep.form', null, 'No access.'); $params = $jo_handler->initializeOneStepForm(); $params['submit_url'] = $this->generateUrl('jo_onestep_submit'); $params['return_url'] = $this->generateUrl('jo_onestep_form'); $params['map_js_file'] = $gis->getJSJOFile(); $params['vmfgs'] = $em->getRepository(VehicleManufacturer::class)->findAll(); $params['vmakes'] = $em->getRepository(Vehicle::class)->findAll(); $template = $params['template']; // response return $this->render($template, $params); } public function oneStepSubmit(Request $req, JobOrderHandlerInterface $jo_handler) { $this->denyAccessUnlessGranted('jo_onestep.form', null, 'No access.'); // initialize error list $error_array = []; $id = -1; $error_array = $jo_handler->processOneStepJobOrder($req, $id); // check if any errors were found if (!empty($error_array)) { // return validation failure response return $this->json([ 'success' => false, 'errors' => $error_array ], 422); } // return successful response return $this->json([ 'success' => 'Changes have been saved!' ]); } /** * @Menu(selected="jo_onestep_edit_form") */ public function oneStepEditForm($id, EntityManagerInterface $em, JobOrderHandlerInterface $jo_handler, GISManagerInterface $gis, MapTools $map_tools) { $this->denyAccessUnlessGranted('jo_onestep.edit', null, 'No access.'); $params = $jo_handler->initializeOneStepEditForm($id, $map_tools); $params['submit_url'] = $this->generateUrl('jo_onestep_edit_submit', ['id' => $id]); $params['return_url'] = $this->generateUrl('jo_open'); $params['map_js_file'] = $gis->getJSJOFile(); $params['vmfgs'] = $em->getRepository(VehicleManufacturer::class)->findAll(); $params['vmakes'] = $em->getRepository(Vehicle::class)->findAll(); $template = $params['template']; // response return $this->render($template, $params); } public function oneStepEditSubmit(Request $req, JobOrderHandlerInterface $jo_handler, $id) { $this->denyAccessUnlessGranted('jo_onestep.edit', null, 'No access.'); $error_array = []; $error_array = $jo_handler->processOneStepJobOrder($req, $id); // check if any errors were found if (!empty($error_array)) { // return validation failure response return $this->json([ 'success' => false, 'errors' => $error_array ], 422); } // return successful response return $this->json([ 'success' => 'Changes have been saved!' ]); } /** * @ParamConverter("jo", class="App\Entity\JobOrder") */ public function popupInfo(JobOrder $jo) { if ($jo == null) return new Response('No job order data'); return $this->render('job-order/popup.html.twig', [ 'jo' => $jo ]); } /** * @ParamConverter("jo", class="App\Entity\JobOrder") */ public function tracker( EntityManagerInterface $em, RiderTracker $rider_tracker, GISManagerInterface $gis_manager, JobOrder $jo ) { if ($jo === null) return new Response('No job order data'); $rider = $jo->getRider(); // get map $params['jo'] = $jo; $params['rider'] = $rider; $params['rider_pos'] = $rider_tracker->getRiderLocation($rider->getID()); $params['service_type'] = CMBServiceType::getName($jo->getServiceType()); $params['map_js_file'] = $gis_manager->getJSInitFile(); return $this->render('job-order/tracker.html.twig', $params); } /** * @Menu(selected="jo_walkin_form") */ public function walkInForm(EntityManagerInterface $em, JobOrderHandlerInterface $jo_handler) { $this->denyAccessUnlessGranted('jo_walkin.form', null, 'No access.'); $params = $jo_handler->initializeWalkinForm(); $params['submit_url'] = $this->generateUrl('jo_walkin_submit'); $params['return_url'] = $this->generateUrl('jo_walkin_form'); $params['vmfgs'] = $em->getRepository(VehicleManufacturer::class)->findAll(); $params['vmakes'] = $em->getRepository(Vehicle::class)->findAll(); $params['hubs'] = $em->getRepository(Hub::class)->findAll(); $template = $params['template']; // response return $this->render($template, $params); } public function walkInSubmit(Request $req, JobOrderHandlerInterface $jo_handler) { $this->denyAccessUnlessGranted('jo_walkin.form', null, 'No access.'); // initialize error list $error_array = []; $id = -1; $error_array = $jo_handler->processWalkinJobOrder($req, $id); // check if any errors were found if (!empty($error_array)) { // return validation failure response return $this->json([ 'success' => false, 'errors' => $error_array ], 422); } // return successful response return $this->json([ 'success' => 'Changes have been saved!' ]); } /** * @Menu(selected="jo_walkin_edit_form") */ public function walkInEditForm($id, EntityManagerInterface $em, JobOrderHandlerInterface $jo_handler) { $this->denyAccessUnlessGranted('jo_walkin.edit', null, 'No access.'); $params = $jo_handler->initializeWalkinEditForm($id); $params['submit_url'] = $this->generateUrl('jo_walkin_edit_submit', ['id' => $id]); $params['return_url'] = $this->generateUrl('jo_open'); $params['vmfgs'] = $em->getRepository(VehicleManufacturer::class)->findAll(); $params['vmakes'] = $em->getRepository(Vehicle::class)->findAll(); $params['hubs'] = $em->getRepository(Hub::class)->findAll(); $template = $params['template']; // response return $this->render($template, $params); } public function walkInEditSubmit(Request $req, JobOrderHandlerInterface $jo_handler) { $this->denyAccessUnlessGranted('jo_walkin.edit', null, 'No access.'); $error_array = []; $error_array = $jo_handler->processOneStepJobOrder($req, $id); // check if any errors were found if (!empty($error_array)) { // return validation failure response return $this->json([ 'success' => false, 'errors' => $error_array ], 422); } // return successful response return $this->json([ 'success' => 'Changes have been saved!' ]); } }