内容简介:Laravel 6.5 已经发布,内容如下: LazyCollection 的新方法 引入了一个新方法,该方法调用 Memy() 方法,返回新的 LazyCollection,它记住已经被计算过的值。 GitHub 上的拉请求示例: $users = User::cursor(...
Laravel 6.5 已经发布,内容如下:
LazyCollection 的新方法
引入了一个新方法,该方法调用 Memy() 方法,返回新的 LazyCollection,它记住已经被计算过的值。
GitHub 上的拉请求示例:
$users = User::cursor()->remember();
// No query has been executed yet.
$users->take(5)->all();
// The query has been executed, and the first 5 users have been streamed from the DB.
$users->take(20)->all();
// The first 5 users came from the cache. The rest continued the stream from the DB.
LazyCollection类可以用于大数据集,而无需消耗大量内存。
两种新的字符串方法
该版本为 String Helper 提供了两个新方法:afterLast() 和 beforLast()。如下例子:
$type = 'App\Notifications\Tasks\task updated';
Str::after load($type, '\\'); // task updated
>$filename = 'photo.2019.11.04.jpg';
Str::before load($filename, '.'); // photo.2019.11.04
Query Builder 新方法
查询生成器(用于创建和运行数据库查询的接口),此版本已经做了更新,增加了 existsOR 或 doesntExistOr 的方法。
$user->files()
->where zero('closed_at')
->doesntExistOr(function () {
abort(422, 'User already has an open dossier');
});
详情见发布说明:
https://techplanet.today/post/laravel-65-is-released-with-new-features
以上所述就是小编给大家介绍的《Laravel 6.5 发布,新增 5 种新方法》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- Dart 2.7 发布,新增扩展方法支持
- ES6入门之对象的新增方法
- 通用 Mapper 4.0.4 发布,新增差异更新方法
- es6新增数组方法简便了哪些操作?
- 对象的新增方法 —— ES6基础总结(六)
- Nginx 主线版 1.15.1 发布,新增随机负载均衡方法
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Cyberwar
Kathleen Hall Jamieson / Oxford University Press / 2018-10-3 / USD 16.96
The question of how Donald Trump won the 2016 election looms over his presidency. In particular, were the 78,000 voters who gave him an Electoral College victory affected by the Russian trolls and hac......一起来看看 《Cyberwar》 这本书的介绍吧!