當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Route::setParameter方法代碼示例

本文整理匯總了PHP中Illuminate\Routing\Route::setParameter方法的典型用法代碼示例。如果您正苦於以下問題:PHP Route::setParameter方法的具體用法?PHP Route::setParameter怎麽用?PHP Route::setParameter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Routing\Route的用法示例。


在下文中一共展示了Route::setParameter方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next, $obscuredParameter = 'id')
 {
     $hashids = new Hashids(config('obscure.salt'), config('obscure.length'), config('obscure.alphabet'));
     // decode form request hashs
     if ($request->request->has($obscuredParameter)) {
         $request->request->add([$obscuredParameter => $hashids->decode($request->request->get($obscuredParameter))[0]]);
     }
     // decode route hashs
     if ($this->route->parameter($obscuredParameter)) {
         $this->route->setParameter($obscuredParameter, $hashids->decode($this->route->parameter($obscuredParameter))[0]);
     }
     return $next($request);
 }
開發者ID:sschlein,項目名稱:obscure,代碼行數:20,代碼來源:Obscure.php

示例2: substituteImplicitBindings

 /**
  * Substitute the implicit Eloquent model bindings for the route.
  *
  * @param  \Illuminate\Routing\Route  $route
  * @return void
  */
 public function substituteImplicitBindings($route)
 {
     $parameters = $route->parameters();
     foreach ($route->signatureParameters(Model::class) as $parameter) {
         $class = $parameter->getClass();
         if (array_key_exists($parameter->name, $parameters) && !$route->getParameter($parameter->name) instanceof Model) {
             $method = $parameter->isDefaultValueAvailable() ? 'first' : 'firstOrFail';
             $model = $class->newInstance();
             $route->setParameter($parameter->name, $model->where($model->getRouteKeyName(), $parameters[$parameter->name])->{$method}());
         }
     }
 }
開發者ID:samlev,項目名稱:framework,代碼行數:18,代碼來源:Router.php

示例3: substituteBindings

 /**
  * Substitute the route bindings onto the route.
  *
  * @param  \Illuminate\Routing\Route  $route
  * @return \Illuminate\Routing\Route
  */
 protected function substituteBindings($route)
 {
     foreach ($route->parameters() as $key => $value) {
         if (isset($this->binders[$key])) {
             $route->setParameter($key, $this->performBinding($key, $value, $route));
         }
     }
     return $route;
 }
開發者ID:hramose,項目名稱:Sistema-Control-de-Almacen,代碼行數:15,代碼來源:Router.php

示例4: substituteImplicitBindings

 /**
  * Substitute the implicit Eloquent model bindings for the route.
  *
  * @param  \Illuminate\Routing\Route  $route
  * @return void
  */
 protected function substituteImplicitBindings($route)
 {
     $parameters = $route->parameters();
     foreach ($route->signatureParameters(Model::class) as $parameter) {
         $class = $parameter->getClass();
         if (array_key_exists($parameter->name, $parameters)) {
             $method = $parameter->isDefaultValueAvailable() ? 'find' : 'findOrFail';
             $route->setParameter($parameter->name, $class->newInstance()->{$method}($parameters[$parameter->name]));
         }
     }
 }
開發者ID:janhartigan,項目名稱:framework,代碼行數:17,代碼來源:Router.php


注:本文中的Illuminate\Routing\Route::setParameter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。