/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle(Request $request, Closure $next) { if (Auth::check()) { return new RedirectResponse(URL::route('home')); } return $next($request); }
public function create($modelName, $item = null, ModelConfig $config = null) { $page = new Page(); $header = new PageHeader(); $header->setText('Create ' . $modelName); if ($item != null && isset($item->id)) { $model = $this->aujaConfigurator->getModel($modelName); $displayField = $this->aujaConfigurator->getDisplayField($model, $config); $header->setText('Edit ' . (isset($item->{$displayField}) ? $item->{$displayField} : $modelName)); $deleteButton = new Button(); $deleteButton->setText(Lang::trans('Delete')); $deleteButton->setConfirmationMessage(Lang::trans('Are you sure?')); $deleteButton->setTarget(URL::route($this->aujaRouter->getDeleteName($modelName), $item->id)); $deleteButton->setMethod('delete'); $header->addButton($deleteButton); } $page->addPageComponent($header); $form = new Form(); $action = $item == null || !isset($item->id) ? URL::route($this->aujaRouter->getStoreName($modelName)) : URL::route($this->aujaRouter->getUpdateName($modelName), $item->id); $form->setAction($action); $form->setMethod($item == null ? 'POST' : 'PUT'); $model = $this->aujaConfigurator->getModel($modelName); $visibleFields = $this->aujaConfigurator->getVisibleFields($model, $config); foreach ($visibleFields as $columnName) { $column = $model->getColumn($columnName); $formItem = $this->formItemFactory->getFormItem($model, $column, $item); $form->addFormItem($formItem); } $submit = new SubmitFormItem(); $submit->setText(Lang::trans('Submit')); $form->addFormItem($submit); $page->addPageComponent($form); return $page; }
/** * Generate the html for the given items * @param $items */ private function generateHtmlFor($items) { $this->menu .= '<ol class="dd-list">'; foreach ($items as $item) { $this->menu .= "<li class=\"dd-item\" data-id=\"{$item->id}\">"; $editLink = URL::route('dashboard.menuitem.edit', [$this->menuId, $item->id]); $style = $item->isRoot() ? 'none' : 'inline'; $this->menu .= <<<HTML <div class="btn-group" role="group" aria-label="Action buttons" style="display: {$style}"> <a class="btn btn-sm btn-info" style="float:left;" href="{$editLink}"> <i class="fa fa-pencil"></i> </a> <a class="btn btn-sm btn-danger jsDeleteMenuItem" style="float:left; margin-right: 15px;" data-item-id="{$item->id}"> <i class="fa fa-times"></i> </a> </div> HTML; $handleClass = $item->isRoot() ? 'dd-handle-root' : 'dd-handle'; if (isset($item->icon) && $item->icon != '') { $this->menu .= "<div class=\"{$handleClass}\"><i class=\"{$item->icon}\" ></i> {$item->title}</div>"; } else { $this->menu .= "<div class=\"{$handleClass}\">{$item->title}</div>"; } if ($this->hasChildren($item)) { $this->generateHtmlFor($item->items); } $this->menu .= '</li>'; } $this->menu .= '</ol>'; }
public function postPayment() { $payer = new Payer(); $payer->setPaymentMethod('paypal'); $item_1 = new Item(); $item_1->setName('Item 1')->setCurrency('USD')->setQuantity(2)->setPrice('150'); // unit price $item_2 = new Item(); $item_2->setName('Item 2')->setCurrency('USD')->setQuantity(4)->setPrice('70'); $item_3 = new Item(); $item_3->setName('Item 3')->setCurrency('USD')->setQuantity(1)->setPrice('20'); // add item to list $item_list = new ItemList(); $item_list->setItems(array($item_1, $item_2, $item_3)); $amount = new Amount(); $amount->setCurrency('USD')->setTotal(580); $transaction = new Transaction(); $transaction->setAmount($amount)->setItemList($item_list)->setDescription('Your transaction description'); $redirect_urls = new RedirectUrls(); $redirect_urls->setReturnUrl(URL::route('payment.status'))->setCancelUrl(URL::route('payment.status')); $payment = new Payment(); $payment->setIntent('Sale')->setPayer($payer)->setRedirectUrls($redirect_urls)->setTransactions(array($transaction)); try { $payment->create($this->_api_context); // echo'hello'; // print_r($test);die; } catch (\PayPal\Exception\PPConnectionException $ex) { if (\Config::get('app.debug')) { echo "Exception: " . $ex->getMessage() . PHP_EOL; $err_data = json_decode($ex->getData(), true); exit; } else { die('Some error occur, sorry for inconvenient'); } } if (is_array($payment->getLinks()) || is_object($payment->getLinks())) { foreach ($payment->getLinks() as $link) { echo 'reached'; if ($link->getRel() == 'approval_url') { $redirect_url = $link->getHref(); break; } } } // add payment ID to session Session::put('paypal_payment_id', $payment->getId()); dd(Session::all()); if (isset($redirect_url)) { // redirect to paypal return Redirect::away($redirect_url); } return Redirect::route('original.route')->with('error', 'Unknown error occurred'); }
public function doLogin() { // validate the info, create rules for the inputs $rules = array('username' => 'required|min:5', 'password' => 'required|min:6'); // run the validation rules on the inputs from the form $validator = Validator::make(Input::all(), $rules); // if the validator fails, redirect back to the form if ($validator->fails()) { return Redirect::route(UserItem::loginRoute(), UserItem::loginRouteParams())->withErrors($validator)->withInput(Input::except('password')); // send back the input (not the password) so that we can repopulate the form } else { // create our user data for the authentication $userdata = array('username' => Input::get('username'), 'password' => Input::get('password')); // attempt to do the login if (Auth::validate($userdata)) { // Valid Login $valid_login = true; // Get User $user = UserItem::findUser($userdata["username"]); // Check if User Disabled if (!$user->isEnabled()) { return Redirect::route(UserItem::loginRoute(), UserItem::loginRouteParams())->with(FLASH_MSG_ERROR, trans("auth-module::message.account_disabled")); } // Trigger Login Event & Validate mergeEventFireResponse(true, Event::fire('user.login_validate', array($user, &$valid_login))); // Check Valid if ($valid_login) { // Do Login Auth::login($user); // Add Login Log LoginLogItem::addLog($user, true); // Trigger Valid Login Event Event::fire('user.valid_login', array($user)); // validation successful! return Redirect::intended(URL::route(UserItem::dashboardRoute()))->with(FLASH_MSG_INFO, trans("auth-module::message.success_login")); } else { // Add Login Log LoginLogItem::addLog($user, false); // Trigger Invalid Login Event Event::fire('user.invalid_login', array($userdata['username'])); // validation not successful, send back to form return Redirect::route(UserItem::loginRoute(), UserItem::loginRouteParams())->with(FLASH_MSG_ERROR, trans("auth-module::message.invalid_login"))->withInput(Input::except('password')); } } else { // Add Login Log LoginLogItem::addLogUsername($userdata["username"], false); // Trigger Invalid Login Event Event::fire('user.invalid_login', array(Input::get('username'))); // validation not successful, send back to form return Redirect::route(UserItem::loginRoute(), UserItem::loginRouteParams())->with(FLASH_MSG_ERROR, trans("auth-module::message.invalid_login"))->withInput(Input::except('password')); } } }
public function url() { if (isset($this->options['url'])) { return $this->options['url']; } $id = array_key_exists('id', $this->options) ? $this->options['id'] : null; $queryString = array_key_exists('queryString', $this->options) ? $this->options['queryString'] : null; $url = URL::route('module', array(Platform::getModule(), $this->type, $id)); if (count($queryString)) { $url .= '?' . http_build_query($queryString); } return $url; }
/** * @param View $view */ public function compose(View $view) { $availableModules = $this->moduleModel->listAvailableModules(); foreach ($availableModules as $availableModule) { $name = $availableModule->name; if ($this->gate->allows($name)) { $this->modules = "<li><a href='" . URL::route($availableModule->route) . "'><i class='" . $availableModule->icon . "'></i><span>{$availableModule->label}</span></a></li>"; } else { $this->modules = null; } $view->with('modules', $this->modules); } }
public function handle($request, \Closure $next) { if (!$this->credentials->check()) { $this->logger->info('User tried to access a page without being logged in', ['path' => $request->path()]); if ($request->ajax()) { throw new UnauthorizedHttpException('Action Requires Login'); } return Redirect::guest(URL::route('account.login'))->with('error', 'You must be logged in to perform that action.'); } if (!$this->credentials->hasAccess($level = $this->level())) { $this->logger->warning('User tried to access a page without permission', ['path' => $request->path(), 'permission' => $level]); throw new AccessDeniedHttpException(ucfirst($level) . ' Permissions Are Required'); } }
/** * Display a listing of the comments. * * @param int $postId * * @return \Illuminate\Http\JsonResponse */ public function index($postId) { $post = PostRepository::find($postId, ['id']); if (!$post) { Session::flash('error', 'The post you were viewing has been deleted.'); return Response::json(['success' => false, 'code' => 404, 'msg' => 'The post you were viewing has been deleted.', 'url' => URL::route('blog.posts.index')], 404); } $comments = $post->comments()->get(['id', 'version']); $data = []; foreach ($comments as $comment) { $data[] = ['comment_id' => $comment->id, 'comment_ver' => $comment->version]; } return Response::json(array_reverse($data)); }
public function postPayment(Request $request) { $quantity = $request->get('quantity'); $payer = new Payer(); $payer->setPaymentMethod('paypal'); $item_1 = new Item(); $item_1->setName(trans('store.paypal.item_name1') . env('PAYPAL_POINTS_PER_DOLLAR', 1000) . trans('store.paypal.item_name2'))->setCurrency('USD')->setQuantity($quantity)->setPrice('1'); // unit price // add item to list $item_list = new ItemList(); $item_list->setItems([$item_1]); $amount = new Amount(); $amount->setCurrency('USD')->setTotal($quantity); $transaction = new Transaction(); $transaction->setAmount($amount)->setItemList($item_list)->setDescription('Your transaction description'); $redirect_urls = new RedirectUrls(); $redirect_urls->setReturnUrl(URL::route('payment.status'))->setCancelUrl(URL::route('payment.status')); $payment = new Payment(); $payment->setIntent('Sale')->setPayer($payer)->setRedirectUrls($redirect_urls)->setTransactions([$transaction]); try { $payment->create($this->_api_context); } catch (\PayPal\Exception\PPConnectionException $ex) { if (\Config::get('app.debug')) { echo 'Exception: ' . $ex->getMessage() . PHP_EOL; $err_data = json_decode($ex->getData(), true); exit; } else { die('Some error occur, sorry for inconvenient'); } } foreach ($payment->getLinks() as $link) { if ($link->getRel() == 'approval_url') { $redirect_url = $link->getHref(); break; } } // add payment ID to session Session::put('paypal_payment_id', $payment->getId()); Session::save(); if (isset($redirect_url)) { // redirect to paypal return Redirect::away($redirect_url); } return Redirect::route('original.route')->with('error', 'Unknown error occurred'); }
/** * Builds a menu for a single model entry, where the model has multiple relationships with other models. * * The menu will include: * - An Edit LinkMenuItem; * - A SpacerMenuItem; * - For each of the Relations, a LinkMenuItem for the associated model. * * @param String $modelName the name of the model. * @param int $modelId the id of the model entry. * @param Relation[] $relations the Relations this model has with associated models. * * @return Menu the Menu, which can be configured further. */ public function create($modelName, $modelId, array $relations, ModelConfig $config = null) { $menu = new Menu(); $addMenuItem = new LinkMenuItem(); $addMenuItem->setText(Lang::trans('Edit')); $addMenuItem->setTarget(URL::route($this->aujaRouter->getEditName($modelName), $modelId)); $menu->addMenuItem($addMenuItem); $spacerMenuItem = new SpacerMenuItem(); $spacerMenuItem->setText(Lang::trans('Properties')); $menu->addMenuItem($spacerMenuItem); foreach ($relations as $relation) { $otherModelName = $relation->getRight()->getName(); $associationMenuItem = new LinkMenuItem(); $associationMenuItem->setText(Lang::trans(str_plural($otherModelName))); $associationMenuItem->setTarget(URL::route($this->aujaRouter->getAssociationMenuName($modelName, $otherModelName), $modelId)); $menu->addMenuItem($associationMenuItem); } return $menu; }
/** * Queue the sending of the password reset email. * * @return \Illuminate\Http\Response */ public function postReset() { $input = Binput::only('email'); $val = UserRepository::validate($input, array_keys($input)); if ($val->fails()) { return Redirect::route('account.reset')->withInput()->withErrors($val->errors()); } $this->throttler->hit(); try { $user = Credentials::getUserProvider()->findByLogin($input['email']); $code = $user->getResetPasswordCode(); $mail = ['link' => URL::route('account.password', ['id' => $user->id, 'code' => $code]), 'email' => $user->getLogin(), 'subject' => Config::get('core.name') . ' - Password Reset Confirmation']; Mail::queue('emails.reset', $mail, function ($message) use($mail) { $message->to($mail['email'])->subject($mail['subject']); }); return Redirect::route('account.reset')->with('success', 'Check your email for password reset information.'); } catch (UserNotFoundException $e) { return Redirect::route('account.reset')->with('error', 'That user does not exist.'); } }
/** * Builds a menu for a single model entry, where the model has exactly one relationship with another model. * * The menu will include: * - An Edit LinkMenuItem to edit the model entry. * - A SpacerMenuItem with the name of the associated model; * - An Add LinkMenuItem to add an entry of the associated model; * - A ResourceMenuItem to hold entries of the associated model. * * @param String $modelName The name of the model. * @param int $modelId The id of the model entry. * @param Relation $relation The Relation this model has with the associated model. * @param ModelConfig $config (optional) The `ModelConfig` to use. * * @return Menu The Menu, which can be configured further. */ public function create($modelName, $modelId, Relation $relation, ModelConfig $config = null) { $otherModelName = $relation->getRight()->getName(); $menu = new Menu(); $editMenuItem = new LinkMenuItem(); $editMenuItem->setText(Lang::trans('Edit')); $editMenuItem->setTarget(URL::route($this->aujaRouter->getEditName($modelName), $modelId)); $menu->addMenuItem($editMenuItem); $headerMenuItem = new SpacerMenuItem(); $headerMenuItem->setText(Lang::trans(str_plural($otherModelName))); $menu->addMenuItem($headerMenuItem); $addMenuItem = new LinkMenuItem(); $addMenuItem->setText(sprintf('%s %s', Lang::trans('Add'), Lang::trans($otherModelName))); $addMenuItem->setIcon(Icons::ion_plus); $addMenuItem->setTarget(URL::route($this->aujaRouter->getCreateAssociationName($modelName, $otherModelName), $modelId)); $menu->addMenuItem($addMenuItem); $resourceMenuItem = new ResourceMenuItem(); $resourceMenuItem->setTarget(URL::route($this->aujaRouter->getAssociationName($modelName, $otherModelName), $modelId)); $menu->addMenuItem($resourceMenuItem); return $menu; }
/** * Builds a simple menu for given model, where typically this model should not have any relations to other models. * * The menu will include: * - An Add LinkMenuItem; * - A SpacerMenuItem with the model's name; * - A ResourceMenuItem to hold entries of the model. * * @param String $modelName The name of the model. * @param ModelConfig $config (optional) The `ModelConfig` to use. * * @return Menu the Menu, which can be configured further. */ public function create($modelName, ModelConfig $config = null) { $menu = new Menu(); $addMenuItem = new LinkMenuItem(); $addMenuItem->setText(Lang::trans('Add')); $addMenuItem->setIcon(Icons::ion_plus); $addMenuItem->setTarget(URL::route($this->aujaRouter->getCreateName($modelName))); $menu->addMenuItem($addMenuItem); $spacerMenuItem = new SpacerMenuItem(); $spacerMenuItem->setText(Lang::trans($modelName)); $menu->addMenuItem($spacerMenuItem); $resourceMenuItem = new ResourceMenuItem(); $resourceMenuItem->setTarget(URL::route($this->aujaRouter->getIndexName($modelName))); $model = $this->aujaConfigurator->getModel($modelName); if ($this->aujaConfigurator->isSearchable($model, $config)) { $target = urldecode(URL::route($this->aujaRouter->getIndexName($modelName), ['q' => '%s'])); /* urldecode because the '%' gets escaped. */ $property = new Searchable($target); $resourceMenuItem->addProperty($property); } $menu->addMenuItem($resourceMenuItem); return $menu; }
/** * Get the delete link for this trick. * * @return string */ public function deleteLink() { return URL::route('tricks.delete', [$this->resource->slug]); }
/** * Resend the activation email of an existing user. * * @param int $id * * @return \Illuminate\Http\Response */ public function resend($id) { $user = UserRepository::find($id); $this->checkUser($user); if ($user->activated) { return Redirect::route('account.resend')->withInput()->with('error', 'That user is already activated.'); } $code = $user->getActivationCode(); $mail = ['url' => URL::to(Config::get('core.home', '/')), 'link' => URL::route('account.activate', ['id' => $user->id, 'code' => $code]), 'email' => $user->getLogin(), 'subject' => Config::get('core.name') . ' - Activation']; Mail::queue('emails.resend', $mail, function ($message) use($mail) { $message->to($mail['email'])->subject($mail['subject']); }); return Redirect::route('users.show', ['users' => $id])->with('success', 'The user\'s activation email has been sent successfully.'); }
/** * Get the delete link for this trick. * * @return string */ public function deleteLink() { return URL::route('tricks.delete', [$this->wrappedObject->slug]); }
public function url() { return URL::route('module', $this->url); }
/** * Builds a Resource instance for given items. * This is typically used when a ResourceMenuItem triggers a call for items. * * This method also supports pagination, either manually or automatically. * To automatically use pagination, simply provide a Paginator as items. * * @param String $modelName the name of the model the items represent. * @param array|Paginator $items an array of instances of the model to be shown, or a Paginator containing the instances. * @param String $targetUrl (optional) The target url for the items. Must contain '%d' in the place of the item id. * @param String $nextPageUrl (optional) The url to the next page, if any. * @param int $offset (optional) The offset to start the order from. * @param ModelConfig $config (optional) The `ModelConfig` to use. * * @return Resource The built LinkMenuItems. */ public function create($modelName, $items, $targetUrl = null, $nextPageUrl = null, $offset = -1, ModelConfig $config = null) { // TODO: create separate methods for pagination and no pagination? /* Extract items from Paginator if necessary */ $paginator = null; if ($items instanceof Paginator) { $paginator = $items; $items = $paginator->getCollection(); if ($offset == -1) { $offset = ($paginator->getCurrentPage() - 1) * $paginator->getPerPage(); } } /* If the offset is not set, use no offset */ if ($offset == -1) { $offset = 0; } /* No items. */ if (count($items) == 0) { return new Resource(); } /* If the items are not iterable */ if (!$items instanceof \IteratorAggregate) { $items = new Collection([$items]); } $model = $this->aujaConfigurator->getModel($modelName); /* Find relations for this model, so we can know the target */ $relations = $this->aujaConfigurator->getRelationsForModel($model); $associationRelations = array(); foreach ($relations as $relation) { if ($relation->getType() == Relation::HAS_MANY || $relation->getType() == Relation::HAS_AND_BELONGS_TO) { $associationRelations[] = $relation; } } /* Build the actual items to return */ $resourceItems = new Resource(); $displayField = $this->aujaConfigurator->getDisplayField($model, $config); $icon = $this->aujaConfigurator->getIcon($model, $config); for ($i = 0; $i < count($items); $i++) { if ($targetUrl != null) { $target = sprintf($targetUrl, $items[$i]->id); } else { if (count($associationRelations) == 0) { $target = URL::route($this->aujaRouter->getEditName($modelName), $items[$i]->id); } else { $target = URL::route($this->aujaRouter->getShowMenuName($modelName), $items[$i]->id); } } $menuItem = new LinkMenuItem(); $menuItem->setText($items[$i]->{$displayField}); $menuItem->setTarget($target); $menuItem->setOrder($offset + $i); $menuItem->setIcon($icon); $resourceItems->addItem($menuItem); } /* Add pagination if necessary */ if ($nextPageUrl != null) { $resourceItems->setNextPageUrl($nextPageUrl); } else { if ($paginator != null && $paginator->getCurrentPage() != $paginator->getLastPage()) { $target = route($this->aujaRouter->getIndexName($modelName), ['page' => $paginator->getCurrentPage() + 1]); $resourceItems->setNextPageUrl($target); } } return $resourceItems; }
public function link_generate_post() { $link = URL::route('confirm_link') . '/' . $this->generateRandomString(); /*va trebui bagat in bd si confirmat*/ return $link; }
/** * Process forget password POST request. * * @param Request $request * @return mixed */ public function postForgotPassword(Request $request) { $this->validate($request, ['email' => 'required|email']); $user = User::where('email', $request['email']); if ($user->count()) { $user = $user->first(); // Generate a new code and password $code = str_random(60); $password = str_random(10); $user->code = $code; $user->password_temp = Hash::make($password); if ($user->save()) { Mail::send('emails.auth.forgot', array('link' => URL::route('account-recover', $code), 'username' => $user->username, 'password' => $password), function ($message) use($user) { $message->to($user->email, $user->username)->subject('Your new password'); }); return Redirect::route('home')->with('global', 'We have sent you a new password by email.'); } } return Redirect::route('account-forgot-password')->with('global', 'Could not request new password.'); }
/** * lumen日志查看 * @return [type] [description] */ public function getLumenData($level) { if (!in_array($level, LogViewer::levels()) && $level != 'all') { return response()->json(['code' => 0, 'result' => '', 'msg' => '异常的日志等级']); } // $level = 'all'; $data = LogViewer::data('lumen', $level); $paginator = new Paginator($data, $this->perPage); $path = (new \ReflectionClass($paginator))->getProperty('path'); $path->setAccessible(true); $path->setValue($paginator, URL::route('logviewer.lumen.show')); if (count($data) > $paginator->perPage()) { $log = array_slice($data, $paginator->firstItem() - 1, $paginator->perPage()); } else { $log = $data; } // return response()->json(['code'=>1, 'result'=>compact('paginator', 'log', 'view'), 'msg'=>'获取成功']); return View::make('logviewer::data', compact('paginator', 'log')); }
public function testPasswordRoute() { $this->assertEquals('http://localhost/boomcms/recover', URL::route('password')); }
/** * Show the log contents. * * @param string $date * @param string|null $level * * @return \Illuminate\Http\Response */ public function getData($date, $level = null) { if (!is_string($level)) { $level = 'all'; } $data = LogViewer::data($date, $level); $paginator = new Paginator($data, $this->perPage); $path = (new \ReflectionClass($paginator))->getProperty('path'); $path->setAccessible(true); $path->setValue($paginator, URL::route('logviewer.index') . '/' . $date . '/' . $level); if (count($data) > $paginator->perPage()) { $log = array_slice($data, $paginator->firstItem() - 1, $paginator->perPage()); } else { $log = $data; } return View::make('logviewer::data', compact('paginator', 'log')); }
public function showDirections() { $theURL = URL::route('directions'); // go the route labeled 'directions' return "Directions go to this URL: {$theURL}"; }
/** * Maps a route to a query of articles * @param string $path A route path like in Route::get(...) * @param string $query A press query * @param array $_options An array of options * @return \Illuminate\Routing\Route A laravel route set * @todo split method in smaller parts * @todo allow post|delete|etc ? */ public function listRoute($path, $query, array $_options = array()) { $as = 'press.' . crc32($query); // fast hash but more collision risks $options = array_merge($this->listRouteOptsWithDefaults(), compact('query', 'as'), $_options); // now that the options are set, the user could have overriden the route // 'as' (the route name) $as = $options['as']; $options['base_route'] = $as; // we share the base route name with the paginated routes $routes = [Route::get($path, array_merge($options, ['as' => $as]))]; // base route // we cannot have optional non-parameters parts in the url, so we must // define other routes if ($options['paginate']) { unset($options['as']); $p = PressPaginator::PAGE_NAME; // redirect page 1 to base path $routes[] = Route::get("{$path}/{$p}/1", function (\Illuminate\Routing\Route $route) use($as) { $url = URL::route($as, $route->parameters(), $abs = false); return redirect($url, 301); }); // other pages $routes[] = Route::get("{$path}/{$p}/{page}", $options)->where('page', '[0-9]+'); } return new ChainableGroup($routes); }
/** * POST method for handling custom actions on the settings page * * @param string $settingsName * * @return JSON */ public function settingsCustomAction($settingsName) { $config = App::make('itemconfig'); $actionFactory = App::make('admin_action_factory'); $actionName = Input::get('action_name', false); //get the action and perform the custom action $action = $actionFactory->getByName($actionName); $data = $config->getDataModel(); $result = $action->perform($data); //override the config options so that we can get the latest App::make('admin_config_factory')->updateConfigOptions(); //if the result is a string, return that as an error. if (is_string($result)) { return Response::json(array('success' => false, 'error' => $result)); } else { if (!$result) { $messages = $action->getOption('messages'); return Response::json(array('success' => false, 'error' => $messages['error'])); } else { $response = array('success' => true, 'actions' => $actionFactory->getActionsOptions(true)); //if it's a download response, flash the response to the session and return the download link if (is_a($result, 'Symfony\\Component\\HttpFoundation\\BinaryFileResponse')) { $file = $result->getFile()->getRealPath(); $headers = $result->headers->all(); Session::put('administrator_download_response', array('file' => $file, 'headers' => $headers)); $response['download'] = URL::route('admin_file_download'); } else { if (is_a($result, '\\Illuminate\\Http\\RedirectResponse')) { $response['redirect'] = $result->getTargetUrl(); } } return Response::json($response); } } }
public function store() { $getid = Events::select('EventID')->get(); if (!$getid->isEmpty()) { $getid = Events::select('EventID')->orderBy('EventID', 'desc')->first()->get(); foreach ($getid as $key) { $id = (int) $key->EventID + 1; } } else { $id = 1; } $result = Request::all(); $quoteID = $result['quoteid']; $eventType = $result['eventType']; $downpayment = $result['downpayment']; $userID = Auth::user()->id; $addedDate = date('Y-m-d H:i:s'); try { /* * Insert the new Quote to Database Table 'quote_requests' */ $events = new Events(); $events->EventID = $id; $events->QuoteID = $quoteID; $events->UserID = $userID; $events->EventType = $eventType; $events->AddedDate = $addedDate; $events->save(); Quote_Requests::where('id', $quoteID)->update(['Status' => 'Paid']); } catch (QueryException $e) { } // ### Address // Base Address object used as shipping or billing // address in a payment. [Optional] $addr = Paypalpayment::address(); $addr->setLine1("22/1, Nagavihara Road"); $addr->setLine2("Pitakotte"); $addr->setCity("Pitakotte"); $addr->setState(""); $addr->setPostalCode("10100"); $addr->setCountryCode("SL"); $addr->setPhone("0094773685526"); // ### CreditCard $card = Paypalpayment::creditCard(); $card->setType("visa")->setNumber("4758411877817150")->setExpireMonth("05")->setExpireYear("2019")->setCvv2("456")->setFirstName("Hasitha")->setLastName("Jayasinghe"); // ### FundingInstrument // A resource representing a Payer's funding instrument. // Use a Payer ID (A unique identifier of the payer generated // and provided by the facilitator. This is required when // creating or using a tokenized funding instrument) // and the `CreditCardDetails` $fi = Paypalpayment::fundingInstrument(); $fi->setCreditCard($card); // ### Payer // A resource representing a Payer that funds a payment // Use the List of `FundingInstrument` and the Payment Method // as 'credit_card' $payer = new Payer(); $payer->setPaymentMethod('paypal'); $item_1 = new Item(); $item_1->setName('Quote ID: ' . $quoteID)->setCurrency('USD')->setQuantity(1)->setPrice($downpayment); // unit price // add item to list $item_list = new ItemList(); $item_list->setItems(array($item_1)); $amount = new Amount(); $amount->setCurrency('USD')->setTotal($downpayment); $transaction = new Transaction(); $transaction->setAmount($amount)->setItemList($item_list)->setDescription('Your transaction description'); // ### Payment // A Payment Resource; create one using // the above types and intent as 'sale' $redirect_urls = new RedirectUrls(); $redirect_urls->setReturnUrl(URL::route('payment-status'))->setCancelUrl(URL::route('payment-status')); $payment = new Payment(); $payment->setIntent('order')->setPayer($payer)->setRedirectUrls($redirect_urls)->setTransactions(array($transaction)); try { // ### Create Payment // Create a payment by posting to the APIService // using a valid ApiContext // The return object contains the status; $payment->create($this->_apiContext); } catch (\PPConnectionException $ex) { return "Exception: " . $ex->getMessage() . PHP_EOL; exit(1); } foreach ($payment->getLinks() as $link) { if ($link->getRel() == 'approval_url') { $redirect_url = $link->getHref(); break; } } // add payment ID to session Session::put('paypal_payment_id', $payment->getId()); if (isset($redirect_url)) { // redirect to paypal return Redirect::away($redirect_url); } return Redirect::route('original-route')->with('error', 'Unknown error occurred'); dd($payment); }
/** * Create a new authentication controller instance. * * @return void */ public function __construct() { $this->middleware('guest', ['except' => 'getLogout']); $this->loginPath = URL::route('signin.index'); $this->redirectPath = URL::route('signup.index'); }
/** * Attribute Links * @return mixed */ public function getLinksAttribute() { return ['show' => URL::route('api.v1.tasks.show', $this->id), 'run' => URL::route('api.v1.tasks.run', $this->id), 'rerun' => URL::to('/api/v1/tasks/run/' . $this->id . '/?force=true')]; }