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


PHP Route::parameter方法代码示例

本文整理汇总了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);
 }
开发者ID:sschlein,项目名称:obscure,代码行数:20,代码来源:Obscure.php

示例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);
 }
开发者ID:rabbitcms,项目名称:backend,代码行数:56,代码来源:MediaController.php

示例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;
 }
开发者ID:yinniermei,项目名称:active,代码行数:15,代码来源:Active.php

示例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);
         }
     }
 }
开发者ID:swayok,项目名称:PeskyCMF,代码行数:13,代码来源:InjectsDbObjects.php

示例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;
 }
开发者ID:rabbitcms,项目名称:backend,代码行数:9,代码来源:UsersRequest.php

示例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');
     }
 }
开发者ID:hp197,项目名称:combiner,代码行数:19,代码来源:Combiner.php

示例7: article

 public function article(Route $route)
 {
     $article = Content::query()->with('category')->findOrFail($route->parameter('id'));
     return \View::make('frontend.article', ['article' => $article]);
 }
开发者ID:CaXaPoK-,项目名称:backend-task,代码行数:5,代码来源:ContentController.php

示例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')];
 }
开发者ID:sonusbeat,项目名称:soundcore,代码行数:9,代码来源:TagsRequest.php


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