Laravel 5.0 Documentation
App\Providers\RouteServiceProvider class. The most basic Laravel routes simply accept a URI and a Closure : Route::get('/', function() { return 'Hello World'; }); Route::post('foo/bar', function() database, a 404 error will be thrown. If you wish to specify your own "not found" behavior, pass a Closure as the third argument to the model method: Route::model('user', 'User', function() { throw }); If you wish to use your own resolution logic, you should use the Router::bind method. The Closure you pass to the bind method will receive the value of the URI segment, and should return an instance0 码力 | 242 页 | 1.44 MB | 1 年前3
Laravel 3.2 Documentation Allow the specification of a separate asset base URL for using CDNs. Allow a starter Closure to be defined in bundles.php to be run on Bundle::start. Allow the registration of custom database each time the "home" view is created, an instance of the View will be passed to the registered Closure, allowing you to prepare the view however you wish. Register a composer that handles multiple views: value if the requested input item doesn't exist: $name = Input::get('name', 'Fred'); Using a Closure to return a default value: $name = Input::get('name', function() {return 'Fred';}); Determining0 码力 | 139 页 | 1.13 MB | 1 年前3
Learning LaravelLayout Inheritance 22 Sharing data to all views 24 Using View::share 24 Using View::composer 24 Closure-based composer 24 Class-based composer 24 Execute arbitrary PHP code 25 Chapter 6: Cashier 26 simple API for managing user authorizations by using Gates and Policies. Gates provide a simple closure based approach to authorisation using the AuthServiceProvider while Policies allow you to organise logic into a single location. You can directly bind variable to a specific view or to all views. Closure-based composer use Illuminate\Support\Facades\View; // ... View::composer('*', function ($view)0 码力 | 216 页 | 1.58 MB | 1 年前3
Laravel 5.1 中文文档App\Http\Middleware; use Closure; class RoleMiddleware { /** * 运行请求过滤器. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param string string $role * @return mixed */ public function handle($request, Closure $next, $role) { if (! $request->user()->hasRole($role)) { // 跳转... } App\Http\Middleware; use Closure; class OldMiddleware { /** * 返回请求过滤器 * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed0 码力 | 307 页 | 3.46 MB | 1 年前3
Laravel 5.2 中文文档本文档由 Laravel 学院(LaravelAcademy.org)提供 Laravel 学院致力于提供优质 Laravel 中文学习资源 11 * @param \Closure|string|null $concrete * @param bool $shared * @return void */ public function bind($abstract App\Http\Middleware; use Closure; class OldMiddleware { /** * 返回请求过滤器 * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed mixed */ public function handle($request, Closure $next) { if ($request->input('age') <= 200) { 本文档由 Laravel 学院(LaravelAcademy.org)提供 Laravel 学院致力于提供优质 Laravel 中文学习资源0 码力 | 377 页 | 4.56 MB | 1 年前3
Laravel 5.3 中文文档框架从未打算具有如此明显的特性。在 Laravel 5.3 中,你在控制器构造函数中不再能够直接获取 到 session 变量或认证后的用户实例,因为中间件还未启动。 仍然有替代方案,那就是在控制器构造函数中使用 Closure 来直接定义中间件。请注意,在使用 这个方案的时候,确保你所使用的 Laravel 版本高于 5.3.4: Closure|string|null $concrete * @param bool $shared * @return void */ public function bind($abstract Laravel 中文学习资源 111 use Closure; class CheckAge { /** * 返回请求过滤器 * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed0 码力 | 691 页 | 9.37 MB | 1 年前3
Laravel 5.6 中文文档* @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if ($request->route()->named('profile')) { 前执行一些任务: Closure; class BeforeMiddleware { public function handle($request, Closure $next) { // 执行动作 本文档由 Laravel 学院提供 而下面这个中间件则会在请求处理后执行其任务: Closure; class AfterMiddleware { public function handle($request, Closure $next) { $response = $next($request);0 码力 | 377 页 | 14.56 MB | 1 年前3
Laravel 6.0 中文文档外使用了 illuminate/database,需要更新相应的方法调用: /** * Get a fluent query builder instance. * * @param \Closure|\Illuminate\Database\Query\Builde r|string $table * @param string|null $as * @param string|null 格: /** * Register a binding with the container. * * @param string|array $abstract * @param \Closure|string|null $concrete * @param bool $shared * @return void * @throws \Exception */ public function 处理输入请求 * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if ($request->route()->named('profile')) { // }0 码力 | 1442 页 | 14.66 MB | 1 年前3
共 8 条
- 1













