Laravel 3.2 Documentation.................. 79 Building Where Clauses ............................................................................................... 80 where and or_where ................................. ............... 80 where_in, where_not_in, or_where_in, and or_where_not_in ....................................... 81 where_null, where_not_null, or_where_null, and or_where_not_null ............ ............... 81 Nested Where Clauses.................................................................................................. 81 Dynamic Where Clauses .................................0 码力 | 139 页 | 1.13 MB | 1 年前3
Laravel 5.0 Documentation
// }) ->where('name', '[A-Za-z]+'); Route::get('user/{id}', function($id) { // }) ->where('id', '[0-9]+'); Route::get('user/{id}/{name}', function($id, $name) { // }) ->where(['id' => '[0-9]+' request may be accessed via the Request facade, or by type-hinting the Illuminate\Http\Request where dependencies are injected: use Illuminate\Http\Request; Route::get('user/{id}', function(Request you want to be injected into the route: Route::bind('user', function($value) { return User::where('name', $value)->first(); }); There are two ways to manually trigger a 404 error from a route. First0 码力 | 242 页 | 1.44 MB | 1 年前3
Laravel 5.1 中文文档return $name; }); 2.3 正则约束 可以使用路由实例上的 where 方法来约束路由参数的格式。where 方法接收参数名和一个正 则表达式来定义该参数如何被约束: Route::get('user/{name}', function ($name) { // })->where('name', '[A-Za-z]+'); Route::get('user/{id}' function ($id) { // })->where('id', '[0-9]+'); 本文档由 Laravel 学院(LaravelAcademy.org)提供 20 Route::get('user/{id}/{name}', function ($id, $name) { // })->where(['id' => '[0-9]+', 'name' DB::select('select * from users where active = ?', [1]); return view('user.index', ['users' => $users]); } } 传递给 select 方法的第一个参数是原生的 SQL 语句,第二个参数需要绑定到查询的参数绑 定,通常,这些都是 where 字句约束中的值。参数绑定可以避免 SQL0 码力 | 307 页 | 3.46 MB | 1 年前3
Laravel 5.3 中文文档搜索结果进行分页: return Order::search('Star Trek')->get(); return Order::search('Star Trek')->where('user_id', 1)->paginate(); 当然,Scout 还有很多其他特性,具体请查看其文档。 可邮寄对象 注:Laracasts 上有关于该特性的免费视频教程。 Laravel 式以第一个参数传入闭包。 where 默认使用非严格比较 where 现在默认使用非严格比较而不是之前的严格比较,如果你想要进行严格比较,可以使用 whereStrict 方法。 本文档由 Laravel 学院(LaravelAcademy.org)提供 Laravel 学院致力于提供优质 Laravel 中文学习资源 19 where 方法也不再接收第三个参数标识“严格”,你需要基于应用的需求区分调用 方法也不再接收第三个参数标识“严格”,你需要基于应用的需求区分调用 where 或 whereStrict。 控制器 构造函数当中使用 Session 在 Laravel 以前的版本中,你可以在控制器构造函数中获取 session 变量或者认证后的用户实例。 框架从未打算具有如此明显的特性。在 Laravel 5.3 中,你在控制器构造函数中不再能够直接获取 到 session 变量或认证后的用户实例,因为中间件还未启动。0 码力 | 691 页 | 9.37 MB | 1 年前3
Laravel 5.2 中文文档Laravel 学院致力于提供优质 Laravel 中文学习资源 29 $router->bind('user', function($value) { return App\User::where('name', $value)->first(); }); 自定义“Not Found” 如果你想要指定自己的“Not Found”行为,将封装该行为的闭包作为第三个参数传递 给 model DB::select('select * from users where active = ?', [1]); return view('user.index', ['users' => $users]); } } 传递给 select 方法的第一个参数是原生的 SQL 语句,第二个参数需要绑定到查询的参数 绑定,通常,这些都是 where 字句约束中的值。参数绑定可以避免 SQL $user->name; } 使用命名绑定 除了使用?占位符来代表参数绑定外,还可以使用命名绑定来执行查询: $results = DB::select('select * from users where id = :id', ['i d' => 1]); 运行插入语句 使用 DB 门面的 insert 方法执行插入语句。和 select 一样,改方法将原生 SQL 语句作为 第一个参数,将绑定作为第二个参数:0 码力 | 377 页 | 4.56 MB | 1 年前3
Laravel 5.6 中文文档test/user 会返回 John。 正则约束 可以通过路由实例上的 where 方法来约束路由参数的格式。where 方法接收参数名和一个正则表达式来定义该参数如何被约束: Route::get('user/{name}', function ($name) { // $name 必须是字母且不能为空 })->where('name', '[A-Za-z]+'); Route::get('user/{id}' Route::get('user/{id}', function ($id) { // $id 必须是数字 })->where('id', '[0-9]+'); Route::get('user/{id}/{name}', function ($id, $name) { 本文档由 Laravel 学院提供 Laravel 学院致力于提供优质 Laravel 中文学习资源 中文学习资源:http://laravelacademy.org 48 // 同时指定 id 和 name 的数据格式 })->where(['id' => '[0-9]+', 'name' => '[a-z]+']); 使用正则约束还有一个好处就是避免了 user/{id} 和 user/{name} 的混淆。 全局约束 如果想要路由参数在全局范围内被给定正则表达式约束,可以使用0 码力 | 377 页 | 14.56 MB | 1 年前3
Laravel 6.0 中文文档test/user 会返回 John。 正则约束 可以通过路由实例上的 where 方法来约束路由参数的格式。 where 方法接收参数名和一个正则表达式来定义该参数如何被约束: Route::get('user/{name}', function ($name) { // $name 必须是字母且不能为空 })->where('name', '[A-Za-z]+'); Route::get('user/{id}' 中文学习资源:https://xueyuanjun.com 178 // $id 必须是数字 })->where('id', '[0-9]+'); Route::get('user/{id}/{name}', function ($id, $name) { // 同时指定 id 和 name 的数据格式 })->where(['id' => '[0-9]+', 'name' => '[a-z]+']); 使用正则约束还有一个好处就是避免 180 Laravel 路由组件支持除 / 之外的所有字符,如果要在占位符中使 用 / 需要通过 where 条件正则表达式显式允许: Route::get('search/{search}', function ($search) { return $search; })->where('search', '.*'); 注:只有最后一个路由参数片段中才支持编码正斜杠/。 命名路由0 码力 | 1442 页 | 14.66 MB | 1 年前3
Learning Laravelmiddleware 28 Chapter 8: Collections 30 Syntax 30 Remarks 30 Examples 30 Creating Collections 30 where() 30 Nesting 30 Additions 31 Using Get to lookup value or return default 31 Using Contains to https://riptutorial.com/ 2 together: models, views and controllers. Controllers are the main part where most of the work is done. They connect to models to get, create or update data and display the results command. after creating command you can register your command inside app/Console/Kernel.php class where you will find commands property. so you can add your command inside the $command array like : protected0 码力 | 216 页 | 1.58 MB | 1 年前3
The Laravel Handbook
code to GitHub 14. Deployment 15. Dynamic routes 16. Non-web routes 17. Creating commands 18. Where to go from here The goal of this handbook is to get you up and running with Laravel, starting from return view('welcome'); }); To do this we use the view() Laravel helper, which knows where to find the welcome view because Laravel uses a set of conventions. 13 We have folders and files Routes |------------------------------------------------------------------------- | | Here is where you can register web routes for your application. These | routes are loaded by the RouteServiceProvider0 码力 | 111 页 | 14.25 MB | 1 年前3
《Slides Dev Web》02. Introduction aux frameworks PHP
HE-Arc query("SELECT * FROM `personnes` WHERE `id` = :id;"); $query->execute(compact('id')); $personne = $query->fetch(PDO::FETCH_OBJ); ?>0 码力 | 24 页 | 1.03 MB | 1 年前3
共 12 条
- 1
- 2













