Laravel 8.74 发布了
Laravel 8.74 发布了! 更新内容包括: 调试模式检查, 事件的 fakeExcept() 方法,支持Migration 中对 MySQL 全文索引(fulltext index)
Prune 命令中添加了 Except 参数
由Jochen Sengier 提供了 --except 参数支持, 该参数可接收一个模型类名列表组成的数组。示例:
$schedule->command('model:prune', [
'--exclude' => [Test::class, Example::class],
])->daily();
调试模式检查
Joel Mellon 贡献了 hasDebugModeEnabled() 方法,用来检查应用是否在调试模式下进行 :
if (App::hasDebugModeEnabled()) {
// ...
}
事件的 "Fake Except" 方法
Jeffrey Angenent 贡献了一个 fakeExcept() 方法,用来将绑定实例替换为伪造除给定事件之外的所有事件的fake
Event::fakeExcept([
NonImportantEvent::class,
'non-fake-event',
]);
数组 "undot" 方法
Amir Rami 为 Arr 和 Collection 提供了 undot() 方法, 该方法与 Arr::dot() 相反. 可以按照点(.)和键名将一维数组转换成多维数组:
$original = [
'user' => [
'name' => 'foo',
'occupation' => 'bar',
]
];
$dotted = Arr::dot($original);
// Results in...
$dotted = [
'user.name' => 'foo',
'user.occupation' => 'bar',
];
// Converts it back to the original form
Arr::undot($dotted);
字符串反转( Reverse)方法
@netpok 为 Str 类和支持 Stringable 的类提供了 reverse() 方法, 该方法支持字符串反转(同时支持多字节字符) :
$this->assertSame('FooBar', Str::reverse('raBooF'));
$this->assertSame('Teniszütő', Str::reverse('őtüzsineT'));
$this->assertSame('❤MultiByte☆', Str::reverse('☆etyBitluM❤'));
MySQL 的全文索引(Fulltext Index)支持
Taylor Otwell 贡献了MySQL在数据迁移(Migration) 上创建全文索引能力的支持, 未来可能扩展到Postgres上.
Release Notes
您可在 Github 上查看全部新特性及更新. 以下内容来自于changelog:
v8.74.0
新增
- 为Prune命令添加了可选的expect参数 (#39749, be4afcc)
- 新增 Illuminate/Foundation/Application::hasDebugModeEnabled() (#39755)
- 新增 Illuminate/Support/Facades/Event::fakeExcept() 和 Illuminate/Support/Facades/Event::fakeExceptFor() (#39752)
- Added aggregate method to Eloquent passthru (#39772)
- 为 Arr 和 Collection 新增 undot() 方法 (#39729)
- 为 Str 新增字符串反转方法 reverse (#39816)
- 现在可以在数据库通知中使用 databaseType 方法自定义类型列 (#39811)
- 新增全文索引 Fulltext Index (#39821)