Laravel 6.5 已經發布,內容如下:
引入了一個新方法,該方法調用 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
查詢生成器(用於創建和運行資料庫查詢的介面),此版本已經做了更新,增加了 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
[admin
]