首页 > 作文

Laravel 7.4 发布

更新时间:2023-04-08 11:14:10 阅读: 评论:0

laravel 团队昨天发布了 v7.4.0 版本,其中包含相当多的新特性,例如自定义的模型转换器接口、 when 高阶集合代理,以及从查询构建器中清除现有 order 的功能。

高阶的 when 集合代理

loris leiva 贡献了使用高阶代理的能力,它的方法是collection::when()

// pr 中的相关代码$collection->when($condition, function ($collection) u ($item) {    $collection->push($item);});// 现在重构为$collection->when($condition)->push($item);

  

此 pr 使您能够共青团工作总结链接其他高阶代理方法:

// 以前$collection->when($condition, function ($collection) {    $collection->map->parintosomething();});// 现在重构为$collection->when($condition)->map->parintosomething();

  

对于 artisan 命令行增加 expectschoice () 进行选择

adrian nürnberger 提供了一个控制台测试方法,用于在命令行中询问你的选择。

就像下面这样:

$name = $this->choice('what is线路板设计 your name?', ['taylor', 'dayle'], $defaultindex);

  

之前你只能断言此问题的回复,不能测试选择:

$this->artisan('question')  ->expectsquestion('what is your name?', 'taylor')  ->asrtexitcode(0);

  

在 laravel7.4,你可以给出选项,像下面这样做:

$this->artisan('question')  ->expectschoice('what is your name?', 'tay湖心亭看雪教案lor', ['taylor', 'dayle'])  ->asrtexitcode(0);

  

你还可以在第四个参数传入一个 boolean 类型的值,用来保证选择顺序

$this->artisan('question')  ->expectschoice('what is your name?', 'taylor', ['taylor', 'dayle'], true)  ->asrtexitcode(0);

  

为 blade 奇数偶数是什么的 @props 标签添加默认值

@props 拥有了自定义默认值的能科目4安全文明驾驶力

<!-- 以前的版本: -->@props(['type', 'message'])@php    $type = $type ?? 'info'@endphp<!-- laravel >=7.4 -->@props(['type' => 'info', 'message'])

  

castable 接口

brent roo 贡献了一个castable接口,允许castable类型指定其基础类:

// 以前class modelx extends model{    protected $casts = [        'data' => casttodto::class . ':' . mydto::class,    ];}// 现在class modely extends model{    protected $casts = [        'data' => mydto::class,    ];}// 基础类u illuminate\contracts\databa\eloquent\castable;class mydto implements castable{    public static function castusing()    {        return casttodto::class . ':' . static::class;    }}

  

从查询构建器中删除order

jonathan reinink 为查询构建器贡献了一个reorder()方法,用于重置其orderby()

$query = db::table('urs')->orderby('name');$unorderedurs = $query->reorder()->get();

  

重新排序允许您在雄辩的关系中定义默认顺序,并能够在需要时取消:.

class account extends model{    public function urs()    {        return $this->hasmany(ur::class)->orderby('name');    }}// 删除名称 orderby 和 order by email$account->urs()->reorder()->orderby('email');// 同样可以写成:$account->urs()->reorder('email');

  

发行说明

您可以在下面看到新功能和更新的完整列表以及在 github 上看到 [7.3.0 和 7.4.0] 之间的区别(https://github.com/laravel/framework/compa…)

v7.4.0

添加内容

可自定义 make:policy 的存档位置 (#32040, 9d36a36)为集合添加 higherorderwhenproxy (#32148)添加了 illuminate\testing\pendingcommand::expectschoice() (#32139)添加了对于 blade 中 “props” 标记的支持 (#32177)添加了 castable 接口 (#32129, 9cbf908, 651371a)增加了从查询生成器中删除订单的功能 (#32186)

修复

在 pendingmailfake::ndnow() 和 pendingmailfake::nd() (#32093) 中添加了缺少的返回值修复了自定义模型属性转换 (#32118)修复了路由组前缀 (#32135, 870efef)修复固定组件类视图引用 (#32132)

相关更改

删除 swift 邮件绑定程序 (#32165)当运行 stub:publish 命令时发布 console stub (#32096)当运行 make:rule 命令时发布 rule stub (#32097)将 midleware.stub 添加到运行 php artisan stub:publish 时发布的文件中 (#32099)将 factory.stub 添加到运行 php artisan stub:publish 时发布的文件中 (#32100)将 eneder.stub 添加到运行 php artisan stub:publish 时发布的文件中 (#32122)

更多学习内容请访问:

八重樱:腾讯t3-t4标准精品php架构师教程目录大全,只要你看完保证薪资上升一个台阶(持续更新)

本文发布于:2023-04-08 11:14:09,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/zuowen/9a5f639f1092000eb7ad3cfe51209c44.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

本文word下载地址:Laravel 7.4 发布.doc

本文 PDF 下载地址:Laravel 7.4 发布.pdf

标签:自定义   高阶   接口   方法
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图