当前位置: 首页>>代码示例>>PHP>>正文


PHP URL::route方法代码示例

本文整理汇总了PHP中Illuminate\Support\Facades\URL::route方法的典型用法代码示例。如果您正苦于以下问题:PHP URL::route方法的具体用法?PHP URL::route怎么用?PHP URL::route使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Support\Facades\URL的用法示例。


在下文中一共展示了URL::route方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handle

 /**
  * 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);
 }
开发者ID:clarkeash,项目名称:StyleCI,代码行数:15,代码来源:RedirectIfAuthenticated.php

示例2: create

 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;
 }
开发者ID:hramose,项目名称:Auja-Laravel,代码行数:34,代码来源:PageFactory.php

示例3: generateHtmlFor

    /**
     * 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>';
    }
开发者ID:Houbsi,项目名称:Menu,代码行数:34,代码来源:MenuRenderer.php

示例4: postPayment

 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');
 }
开发者ID:sumitglobussoft,项目名称:INSTAGRAM-PANEL,代码行数:53,代码来源:PaypalController.php

示例5: doLogin

 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'));
         }
     }
 }
开发者ID:developeryamhi,项目名称:laravel-admin,代码行数:53,代码来源:AuthController.php

示例6: url

 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;
 }
开发者ID:spescina,项目名称:platform-core,代码行数:13,代码来源:Action.php

示例7: compose

 /**
  * @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);
     }
 }
开发者ID:karthik1407s,项目名称:sparkplug,代码行数:16,代码来源:SidebarComposer.php

示例8: handle

 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');
     }
 }
开发者ID:xhulioh25,项目名称:wiki,代码行数:14,代码来源:Auth.php

示例9: index

 /**
  * 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));
 }
开发者ID:tangtienviet,项目名称:CMS,代码行数:21,代码来源:CommentController.php

示例10: postPayment

 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');
 }
开发者ID:softsolution,项目名称:antVel,代码行数:45,代码来源:PaypalController.php

示例11: create

 /**
  * 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;
 }
开发者ID:hramose,项目名称:Auja-Laravel,代码行数:33,代码来源:MultipleAssociationsIndexMenuFactory.php

示例12: postReset

 /**
  * 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.');
     }
 }
开发者ID:xhulioh25,项目名称:wiki,代码行数:25,代码来源:ResetController.php

示例13: create

 /**
  * 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;
 }
开发者ID:hramose,项目名称:Auja-Laravel,代码行数:37,代码来源:SingleAssociationIndexMenuFactory.php

示例14: create

 /**
  * 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;
 }
开发者ID:hramose,项目名称:Auja-Laravel,代码行数:36,代码来源:NoAssociationsIndexMenuFactory.php

示例15: deleteLink

 /**
  * Get the delete link for this trick.
  *
  * @return string
  */
 public function deleteLink()
 {
     return URL::route('tricks.delete', [$this->resource->slug]);
 }
开发者ID:JEA-pro,项目名称:JEA-JOBS,代码行数:9,代码来源:TrickPresenter.php


注:本文中的Illuminate\Support\Facades\URL::route方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。