本文整理汇总了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]));
}
}
}