public function update() { $orderEntity = false; if ($this->isPost()) { $tableName = zbase_entity('custom_orders')->getTable(); $name = zbase_request_input('name', false); $orderId = zbase_request_input('order_id', false); $amount = zbase_request_input('amount', false); $validators = ['name' => 'required', 'amount' => 'required', 'order_id' => 'required|exists:' . $tableName . ',order_id,name,' . $name . ',total,' . number_format($amount, 2) . ',status,1', 'date' => 'required|date_format:Y-m-d|before:' . zbase_date_now()->addDay(), 'payment_center' => 'required', 'file' => 'required|image']; $messages = ['order_id.exists' => 'Order ID, Name and Amount don\'t match.', 'amount.required' => 'Enter the amount that you deposited or paid.', 'file.required' => 'Kindly upload your deposit or payment slip.', 'file.image' => 'The file you uploaded is not an image.']; $this->validate(zbase_request(), $validators, $messages); $folder = zbase_storage_path() . '/zivsluck/order/receipts/'; $newFilename = zbase_file_name_from_file($_FILES['file']['name'], $orderId, true); $newFilename = zbase_file_upload_image('file', $folder, $newFilename, 'png', [280, null]); if (file_exists($newFilename)) { $orderEntity = zbase_entity('custom_orders')->repository()->byId($orderId); $orderEntity->status = 2; $orderEntity->payment_merchant = zbase_request_input('payment_center', null); $orderEntity->paid_date_at = zbase_request_input('date', null); $orderEntity->payment_tracking_number = zbase_request_input('payment_tracking', null); $orderEntity->save(); $orderEntity->sendPaymentReceiptToShane(); } } zbase_view_pagetitle_set('Update Order'); return $this->view(zbase_view_file('order.update'), compact('orderEntity')); }
protected function _contactUs() { $success = false; if ($this->isPost()) { if (!zbase_captcha_verify()) { return $this->buildFailedValidationResponse(zbase_request(), ['ReCAPTCHA Validation failed.']); } $validatorMessages = ['email.required' => _zt('Email Address is required.'), 'email.email' => _zt('Invalid email address.'), 'comment.required' => _zt('Message is required.'), 'name.required' => _zt('Name is required.')]; $rules = ['email' => 'required|email', 'comment' => 'required', 'name' => 'required']; $valid = $this->validateInputs(zbase_request_inputs(), $rules, $validatorMessages); if (!empty($valid)) { $data = zbase_request_inputs(); $success = zbase_messenger_email('contactus', zbase_request_input('email'), _zt(zbase_site_name() . ' - Contact Us Form - ' . zbase_request_input('name')), zbase_view_file_contents('email.contactus'), $data); if (!empty($success)) { zbase_alert('success', _zt('Message sent!')); zbase()->json()->setVariable('contact_success', 1); if (!zbase_is_json()) { return redirect(zbase_url_previous()); } } else { zbase_alert('error', _zt('There was a problem sending your message. Kindly try again!')); } } } }
public function reset() { if (!$this->authEnabled()) { return $this->notfound('User authentication is disabled.'); } if ($this->isPost()) { return $this->postReset(zbase_request()); } return $this->getReset(zbase_route_input('token', null)); }
public function renderException() { $request = zbase_request(); $e = $this; return response()->view(zbase_view_file('errors.' . $this->getStatusCode()), compact('request', 'e')); }
/** * Return the Response * @param mixed $response * @return mixed */ function zbase_response($response) { // HTTP/1.1 204 No Content // $apiResponse = zbase()->json()->getVariable('api'); // if(!empty($apiResponse) && $apiResponse instanceof \Zbase\Exceptions\HttpException && $apiResponse->getStatusCode() == 204) // { // $response->header('HTTP/1.1 204 No Content'); // return $response; // } $returnNoContent = ''; $errorResponse = false; $xmlResponse = false; $responseFormat = zbase_response_format(); if (zbase_is_json()) { $responseFormat = 'json'; } if ($responseFormat == 'json' || zbase_request_is_ajax()) { $jsonResponse = true; } if ($responseFormat == 'xml') { $xmlResponse = true; } if (zbase_is_angular_template()) { $responseFormat = 'html'; $jsonResponse = false; } if (!empty($jsonResponse)) { $formId = zbase_request_input('_formId', null); if (!empty($formId)) { zbase()->json()->setVariable('_formId', $formId); } zbase()->json()->setVariable('_route', zbase_route_name()); zbase()->json()->setVariable('_package', zbase_view_template_package()); $code = 200; if ($response instanceof \RuntimeException) { $code = $response->getStatusCode(); zbase()->json()->setVariable('statusCode', $code); if ($code !== 200) { $errorResponse = true; zbase()->json()->setVariable('statusMessage', $response->getStatusMessage()); } } /** * its ajax, but method is GET */ if (empty($errorResponse)) { $tokenResponse = zbase_request_input('token', zbase_request_query_input('token', false)); if (!$tokenResponse) { zbase()->json()->setVariable('_token', zbase_csrf_token()); } } zbase()->json()->setVariable('_alerts', ['errors' => zbase_alerts('error'), 'messages' => zbase_alerts('success'), 'info' => zbase_alerts('info'), 'warning' => zbase_alerts('warning')]); $jsonScripts = zbase()->json()->getVariable('_html_script'); $jsonScriptReturn = ''; if (!empty($jsonScripts)) { foreach ($jsonScripts as $jScripts) { if (!empty($jScripts[0])) { $jScripts[0] = str_replace(array('<script type="text/javascript">', '</script>'), '', $jScripts[0]); $jsonScriptReturn .= $jScripts[0] . ';'; } } } zbase()->json()->setVariable('_html_script', str_replace(';;', ';', $jsonScriptReturn)); $forceResponse = zbase_request_input('forceResponse', zbase_request_query_input('forceResponse', false)); /** * JSONP Callback */ $jsonCallback = zbase_request_query_input('callback', zbase_request_query_input('jsonp', false)); if (!$forceResponse) { zbase_alerts_render(); if (!empty($jsonCallback)) { return response()->json(zbase()->json()->getVariables(), $code)->setCallback($jsonCallback); } else { return response()->json(zbase()->json()->getVariables(), $code); } } } if ($response instanceof \RuntimeException) { if ($response->getStatusCode() == '302') { if (zbase_is_json()) { zbase_alerts_render(); if (!empty($jsonCallback)) { return response()->json(zbase()->json()->getVariables(), 302)->setCallback($jsonCallback); } else { return response()->json(zbase()->json()->getVariables(), 302); } } } return $response->render(zbase_request(), $response); } /** * REsponse with a javascript code */ if ($responseFormat == 'javascript') { $response = \Response::make($response, 200); $response->header('Content-Type', 'application/javascript'); } return $response; }
/** * Login * @return */ public function login() { if (!$this->authEnabled()) { return $this->notfound('User authentication is disabled.'); } if ($this->isPost()) { return $this->postLogin(zbase_request()); } return $this->view(zbase_view_file('auth.login')); }