本文整理匯總了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);
}
示例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}());
}
}
}
示例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;
}
示例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]));
}
}
}