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

新增

为 illuminate\http\client\factory 类新增 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