Laravel 3.2 Documentation$callback); 16 Wildcards Forcing a URI segment to be any digit: Route::get('user/(:num)', function($id) { // }); Allowing a URI segment to be any alpha-numeric string: Route::get('post/(:any)' without limitations: Route::get('files/(:all)', function($path) { // }); Allowing a URI segment to be optional: Route::get('page/(:any?)', function($page = 'index') { // }); The 404 frameworks, where the first segment is the controller name, the second is the method, and the remaining segments are passed to the method as arguments. If no method segment is present, the "index" method0 码力 | 139 页 | 1.13 MB | 1 年前3
Learning Laravelresolves Eloquent models defined in routes or controller actions whose variable names match a route segment name. For example: Route::get('api/users/{user}', function (App\User $user) { return $user->email; }); In this example, since the Eloquent $user variable defined on the route matches the {user} segment in the route's URI, Laravel will automatically inject the model instance that has an ID matching Redirect::route('loginPage'); Route Parameters You can use route parameters to get the part of the URI segment. You can define a optional or required route parameter/s while creating a route. Optional parameters0 码力 | 216 页 | 1.58 MB | 1 年前3
Laravel 5.0 Documentation
Router::bind method. The Closure you pass to the bind method will receive the value of the URI segment, and should return an instance of the class you want to be injected into the route: Route::bind('user' Language At Runtime Setting The Fallback Language echo Lang::get('messages.welcome'); The first segment of the string passed to the get method is the name of the language file, and the second is the0 码力 | 242 页 | 1.44 MB | 1 年前3
The Laravel Handbook
Route::get('/dogs/daisy', function () { return view('dog'); }) What we do instead is, we have a dynamic segment in the URL: Route::get('/dogs/{slug}', function () { return view('dog'); }) slug is a0 码力 | 111 页 | 14.25 MB | 1 年前3
共 4 条
- 1













