设为首页收藏本站

LUPA开源社区

 找回密码
 注册
文章 帖子 博客
LUPA开源社区 首页 业界资讯 软件追踪 查看内容

Laravel 6.5发布,新增5种新方法

2019-11-11 17:16| 发布者: joejoe0332| 查看: 189| 评论: 0|原作者: oschina|来自: oschina

摘要: Laravel 6.5已经发布,内容如下: LazyCollection的新方法 引入了一个新方法,该方法调用 Memy() 方法,返回新的LazyCollection,它记住已经被计算过的值。 GitHub 上的拉请求示例: $users = User::cursor()-rememb ...

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


酷毙

雷人

鲜花

鸡蛋

漂亮
  • 快毕业了,没工作经验,
    找份工作好难啊?
    赶紧去人才芯片公司磨练吧!!

最新评论

关于LUPA|人才芯片工程|人才招聘|LUPA认证|LUPA教育|LUPA开源社区 ( 浙B2-20090187 浙公网安备 33010602006705号   

返回顶部