Laravel 10.12版本发布

2023-06-01 laravel 版本 发布

Laravel团队发布了v10.12版本,在Sleep中加入了条件性方法,新的作业超时事件,时区验证参数,等等:

条件性睡眠

Bradie Tilley贡献了在Laravel 10.10中引入的新Sleep类中添加条件的能力:

Sleep::for(1)->second()->unless($task->completed());
Sleep::for(1)->second()->when($task->pending());
 
// Closures
Sleep::for(1)->second()->unless(fn () => $task->completed());
Sleep::for(1)->second()->when(fn () => $task->pending());


工作超时事件发生

Saeed Hosseini贡献了一个JobTimedOut事件,当作业超时时,队列工作者会触发该事件:

use Illuminate\Queue\Events\JobTimedOut;
 
/**
 * The event to listener mappings for the application.
 *
 * @var array<class-string, array<int, class-string>>
 */
protected $listen = [
    JobTimedOut::class => [
        SendJobTimedOutNotification::class,
    ],
];

对Markdown邮件的内联附件支持

Nuno Maduro贡献了对Markdown mailables的内联附件支持:

>这个拉动请求修复了模板上$message变量的markdown访问,
 通过简单地懒惰渲染markdown的时刻,$message变量已经可以作为视图数据。

详情见第47140号拉动请求。


方法不允许的HTTP断言

Azim Kordpour贡献了一个HTTP状态405(方法不允许)的断言,

你可以用它来验证一个路由不响应某些HTTP动词:

$this->get('/')->assertOk();
 
$this->post('/')->assertMethodNotAllowed();
$this->patch('/')->assertMethodNotAllowed();
$this->put('/')->assertMethodNotAllowed();
$this->delete('/')->assertMethodNotAllowed();


Eloquent forceCreateQuietly()方法

Volodya Kurshudyan为Eloquent贡献了一个forceCreateQuietly()方法,

它可以在不触发任何模型事件的情况下强制创建一个模型:

Post::forceCreateQuietly($data);

为时区验证规则添加参数

Artyom Yavdoshchuk增加了对使用时区验证规则的参数的支持:

'timezone' // works as before
'timezone:Africa' // accepts only Africans timezones
'timezone:All' // works the same as without any parameters
'timezone:All_with_BC' // accepts timezones with Backward Compatibility (Europe/Kiev will be accepted)
'timezone:Per_country,US' // accepts only US timezones

下面是拉动请求测试案例中的一个例子:

$v = new Validator(
    $trans,
    ['foo' => 'australia/sydney'],
    ['foo' => 'Timezone:Australia']
);
 
$this->assertFalse($v->passes());

发布说明

你可以在GitHub上看到以下完整的新功能和更新列表以及10.11.0和10.12.0之间的差异。

下面的发行说明直接来自更新日志:

https://github.com/laravel/framework/compare/v10.11.0...v10.12.0
https://github.com/laravel/framework/blob/4e8e644f58cdacd9b330f4bc4fe39b4f58c97270/CHANGELOG.md#v10120-2023-05-23


v10.12.0

新增

添加 Illuminate/Queue/Events/JobTimedOut.php (#47068)
为Illuminate/Support/Sleep添加了when()和unless()方法 (#47114)
为markdown mailables添加内联附件支持(#47140)。
增加了 Illuminate/Testing/Concerns/AssertsStatusCodes::assertMethodNotAllowed() (#47169)
增加了forceCreateQuietly方法(#47162)
为时区验证规则添加了参数(#47171)

修正了

修复了单子和api单子的可创建|可删除|唯一的|except组合(#47098)
不要对DynamoDBClient使用空密钥或秘密(#47144)

已更改

在可验证的删除中删除会话 (#47141)
在Illuminate/Database/Schema/Builder::withoutForeignKeyConstraints()中添加了错误处理并确保重新启用外键约束(#47182)

重构

删除无用的else语句(#47161)


转:

https://laravel-news.com/laravel-10-12-0

相关文章