本文整理汇总了PHP中Illuminate\Routing\Router::pattern方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::pattern方法的具体用法?PHP Router::pattern怎么用?PHP Router::pattern使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Routing\Router
的用法示例。
在下文中一共展示了Router::pattern方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
$router->pattern('id', '[0-9]+');
$router->pattern('slug', '[a-zA-Z0-9\\-]+');
$router->pattern('code', '[a-zA-Z0-9]+');
parent::boot($router);
}
示例2: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
//
$router->pattern('user', '[0-9]+');
$router->pattern('id', '[0-9]+');
parent::boot($router);
}
示例3: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
$router->pattern('id', '[0-9]+');
$router->pattern('letter', '[A-Za-z]+');
parent::boot($router);
//
}
示例4: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
$router->pattern('id', '[0-9]+');
$router->pattern('step', '(clone|install|activate|purge)');
$router->model('log', 'REBELinBLUE\\Deployer\\ServerLog');
parent::boot($router);
}
示例5: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
$router->pattern('id', '[0-9]+');
// Should handle 32n33-sss-img-dd.png exception
$router->pattern('image', '(?P<parent>[0-9n]{2,5}-[\\pL-\\pN\\._-]+)-(?P<suffix>img-[0-9]{2}.png)');
parent::boot($router);
}
示例6: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param Router $router
*/
public function boot(Router $router)
{
$router->pattern('id', '[0-9]+');
$router->pattern('step', '(clone|install|activate|purge)');
$router->model('log', ServerLog::class);
parent::boot($router);
}
示例7: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
$router->pattern('zipcode', '\\d{5}([\\-]?\\d{4})?');
$router->pattern('state', '[a-zA-Z]{2}');
$router->pattern('district', '\\d{1,3}');
$router->pattern('lat', '^[-+]?([1-8]?\\d(\\.\\d+)?|90(\\.0+)?)');
$router->pattern('lng', '[-+]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)');
parent::boot($router);
}
示例8: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
// Sets up our routing tokens.
$router->pattern('board', Board::URI_PATTERN);
$router->pattern('id', '[1-9]\\d*');
$router->model('ban', '\\App\\Ban');
$router->model('board', '\\App\\Board');
$router->model('post', '\\App\\Post');
$router->model('report', '\\App\\Report');
$router->model('role', '\\App\\Role');
$router->bind('user', function ($value, $route) {
if (is_numeric($value)) {
return \App\User::find($value);
} else {
if (preg_match('/^[a-z0-9]{1,64}\\.(?P<id>\\d+)$/i', $value, $matches)) {
return \App\User::find($matches['id']);
}
}
});
$router->bind('role', function ($value, $route) {
if (is_numeric($value)) {
return \App\Role::find($value);
} else {
if (preg_match('/^[a-z0-9]{1,64}\\.(?P<id>\\d+)$/i', $value, $matches)) {
return \App\Role::find($matches['id']);
}
}
});
$router->bind('post_id', function ($value, $route) {
$board = $route->getParameter('board');
if (is_numeric($value) && $board instanceof Board) {
return $board->getThreadByBoardId($value);
}
});
// Binds a matched instance of a {board} as a singleton instance.
$router->matched(function ($route, $request) {
// Binds the board to the application if it exists.
$board = $route->getParameter('board');
if ($board instanceof Board && $board->exists) {
$board->applicationSingleton = true;
//$this->app->instance("\App\Board", $board);
$this->app->singleton("\\App\\Board", function ($app) use($board) {
return $board->load(['assets', 'settings']);
});
}
// Binds the post to the application if it exists.
$post = $route->getParameter('post_id');
if ($post instanceof Post && $post->exists) {
$route->setParameter('post', $post);
//$this->app->instance("\App\Post", $post);
$this->app->singleton("\\App\\Post", function ($app) use($post) {
return $post;
});
}
});
parent::boot($router);
}
示例9: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
*
* @return void
*/
public function boot(Router $router)
{
//
$router->pattern('owner', '[a-zA-Z.0-9_\\-]+');
$router->pattern('project', '[a-zA-Z.0-9_\\-]+');
$router->pattern('commitishPath', '.+');
$router->pattern('commit', '[a-f0-9^]+');
parent::boot($router);
$this->registerBindings();
}
示例10: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
//
$router->pattern('id', '[a-zA-Z0-9]+');
// Every parametters have the name is 'id' are checked before to action in controller
parent::boot($router);
}
示例11: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
$router->pattern('board', Board::URI_PATTERN);
$router->model('board', 'App\\Board');
$router->model('role', 'App\\Role');
parent::boot($router);
}
示例12: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
$router->pattern('artist', '[0-9]+');
$router->pattern('studio', '[-\\w]+');
$router->pattern('event', '[0-9]+');
$router->pattern('piece', '[0-9]+');
$router->pattern('photo', '[0-9]+');
parent::boot($router);
$router->model('artist', 'App\\Artist');
$router->model('piece', 'App\\Piece');
$router->model('photo', 'App\\Photo');
$router->bind('studio', function ($slug) {
return Studio::where('slug', $slug)->firstOrFail();
});
$router->model('event', 'App\\Event');
}
示例13: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
/**
* Username must be Alphanumeric
*/
$router->pattern('username', '[0-9a-zA-Z]+');
parent::boot($router);
}
示例14: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
$router->model('user', 'Coyote\\User');
$router->model('post', 'Coyote\\Post');
$router->model('topic', 'Coyote\\Topic');
$router->pattern('id', '[0-9]+');
$router->pattern('forum', '[A-Za-z\\_\\/]+');
$router->pattern('tag', '([\\p{L}\\p{Mn}0-9\\._+-]+)');
$router->bind('forum', function ($path) {
$result = \Coyote\Forum::where('path', $path)->first();
if (!$result) {
abort(404);
}
return $result;
});
parent::boot($router);
}
示例15: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
$router->pattern('user', '[0-9]+');
$router->bind('user', function ($value) {
return User::where('id', $value)->limit(1)->first();
});
parent::boot($router);
}