本文整理汇总了PHP中Illuminate\Routing\Route::parameter方法的典型用法代码示例。如果您正苦于以下问题:PHP Route::parameter方法的具体用法?PHP Route::parameter怎么用?PHP Route::parameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Routing\Route
的用法示例。
在下文中一共展示了Route::parameter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: resize
public function resize(Route $route)
{
/**
* @var $media MediaModel
*/
$media = MediaModel::query()->find($route->parameter('id'));
$path = storage_path('app/' . $media->path());
$url = $media->url($route->parameter('width'), $route->parameter('height'), $route->parameter('type'));
$filename = public_path($url);
is_file($filename) && unlink($filename);
$width = $route->parameter('width') == '-' ? null : $route->parameter('width');
$height = $route->parameter('height') == '-' ? null : $route->parameter('height');
$img = \Image::make($path);
$aspectRatio = $img->width() / $img->height();
$nwidth = $width;
$nheight = $height;
switch ($route->parameter('type')) {
case 'c':
if ($width !== null || $height !== null) {
if ($width === null) {
$aspect = intval($height * $aspectRatio) / $height;
$nwidth = $img->width();
} else {
if ($height === null) {
$aspect = $width / intval($width / $aspectRatio);
$nheight = $img->height();
} else {
$aspect = $width / $height;
}
}
if ($width !== null && $height !== null) {
if ($aspect < $aspectRatio) {
$img->resize(null, $height, function ($constraint) {
$constraint->aspectRatio();
});
} else {
$img->resize($width, null, function ($constraint) {
$constraint->aspectRatio();
});
}
}
$img->crop($nwidth, $nheight);
}
break;
case 'r':
if ($width !== null || $height !== null) {
$img->resize($width, $height, function ($constraint) {
$constraint->aspectRatio();
});
}
break;
}
\File::makeDirectory(dirname($filename), 0777, true, true);
$img->save($filename, 80);
return \Redirect::to($url);
}
示例3: checkRouteParam
/**
* Check if the parameter of the current route has the correct value
*
* @param $param
* @param $value
*
* @return bool
*/
public function checkRouteParam($param, $value)
{
if (!$this->route) {
return false;
}
return $this->route->parameter($param) == $value;
}
示例4: addParentIdsConditionsForDbObjectInjection
/**
* @param Route $route
* @param CmfDbObject $object
* @param array $conditions
*/
protected function addParentIdsConditionsForDbObjectInjection(Route $route, CmfDbObject $object, array &$conditions)
{
foreach ($route->parameterNames() as $name) {
if ($object->_hasField($name)) {
$conditions[$name] = $route->parameter($name);
}
}
}
示例5: rules
public function rules(Route $route)
{
if ($route->getName() == 'backend.backend.users.update') {
$rules = ['user.email' => 'required|unique:backend_users,email,' . $route->parameter('id'), 'user.active' => 'required', 'groups' => 'required'];
} else {
$rules = ['user.email' => 'required|unique:backend_users,email', 'user.active' => 'required', 'groups' => 'required', 'password' => 'required'];
}
return $rules;
}
示例6: viewCss
/**
* Controller function to output the CSS.
*
* @param Route $route
* @param Request $request
* @param Response $response
*
* @return Response
*/
public function viewCss(Route $route, Request $request, Response $response)
{
if (!$this->isResponseObject($response)) {
return $response;
}
$files = explode(',', $route->parameter('files', ''));
if ($route->parameter('count', 0) != count($files)) {
$this->app->abort(422, 'Length option incorrect');
}
}
示例7: article
public function article(Route $route)
{
$article = Content::query()->with('category')->findOrFail($route->parameter('id'));
return \View::make('frontend.article', ['article' => $article]);
}
示例8: rules
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules(Route $route)
{
return ['name' => 'required|between:4,100', 'permalink' => 'required|between:4,100:unique:tags,permalink' . $route->parameter('tags')];
}