Laravel 团队昨天发布了 v7.5.0,其中包含了框架的一些更新的最新功能、修复和优化:
?
新的 Http 客户端断言
Christoph Rumpel 为 Http 客户端提供了两个新的测试方法:
Http::assertNotSent(function ($request) {
return $request->hasHeader('X-First','foo') &&
$request->url() == 'http://test.com/users' &&
$request['name'] == 'Taylor' &&
$request['role'] == 'Developer';
});
Http::assertNothingSent();
assertNotSent() ?应该返回一个?boolean ?值条件,并带有你需要匹配请求的约束条件。这些方法补充了现有的?assertSent() ?方法,在代码应导致不发送特定请求或不发送请求的情况下提供相反情况的检查。
重命名字段添加枚举支持
根据此功能的?PR?“在迁移中,无法在带有枚举列的表中通过 renameColumn () 或 change () 方法重命名或修改列类型。”
如果我正确理解 PR 的话,你可以在枚举列上面调用?change() ?方法:
更新: PR 作者澄清了 PR 提供的功能:
更新: PR 作者澄清了 PR 提供的功能:
Schema::create('users',function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->increments('age');
$table->enum('color',['red','blue']);
});
// PR 提交前不支持
Schema::table('users',function (Blueprint $table) {
$table->integer('age')->change();
});
// PR 提交前不支持
Schema::table('users',function (Blueprint $table) {
$table->rename('name','username');
});
提醒一下,文档目前提供以下可修改字段类型的说明:
只有以下字段类型支持调用 “changed”: bigInteger, binary,boolean, date, dateTime, dateTimeTz, decimal, integer, json, longText, mediumText, smallInteger, string, text, time, unsignedBigInteger, unsignedInteger 和 unsignedSmallInteger。
?
更多的转换更新
Brent Roose?在?Castable::castUsing ?实现中提供了直接实例化:
class EloquentDataTransferObject extends DataTransferObject implements Castable
{
public static function castUsing()
{
return new DataTransferObjectCaster(static::class);
}
}
在 PR #32225 中了解更多与此相关的功能。 Laravel 7.4 版本引入了 Castable 接口,查看最新版本获取更多详细信息。 Eloquent 修改器 文档是另外一个了解自定义转换的好地方。
发布说明
你可以在下面的 GitHub 链接中看到新功能和更新列表以及?7.4.0 和 7.5.0?之间的区别。 完整版的 Laravel 7.x 发行说明已经在最新版本?v7 更新日志?中:
v7.5.0
新增
为?IlluminateHttpClientFactory ?类新增?assertNotSent() ?和?assertNothingSent() ?方法 (#32197)
- 增加对?
renameColumn() ?的枚举支持 (#32205)
- 支持返回 caster 实例 (#32225)
修复
- 避免超长 URL 破坏邮件布局 (#32189)
- 修复驼峰转换关联名称 (#32217)
- 修复 Blade 组件中合并 boolean 和 null 属性的问题 (#32245)
- 修复 Console 预期的断言顺序 (#32258)
- 修复?
route ?自定义绑定键帮助方法 (#32264)
- 修复 UriValidator 中的双斜线匹配 (修复缓存路由和不缓存路由不一致) (#32260)
- 修复邮件发送 header 设置 (#32272)
优化
- 优化?
Container::resolve() ?方法 (#32194)
- 优化?
data_get() ?方法性能 (#32192)
- 优化?
Str::startsWith() ?(#32243)
原文地址:https://laravel-news.com/laravel-7-5-rel... 译文地址:https://learnku.com/laravel/t/43206
更多学习内容请访问:
八重樱:腾讯T3-T4标准精品PHP架构师教程目录大全,只要你看完保证薪资上升一个台阶(持续更新)?zhuanlan.zhihu.com
? (编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|