侯体宗的博客
  • 首页
  • Hyperf版
  • beego仿版
  • 人生(杂谈)
  • 技术
  • 关于我
  • 更多分类
    • 文件下载
    • 文字修仙
    • 中国象棋ai
    • 群聊
    • 九宫格抽奖
    • 拼图
    • 消消乐
    • 相册

Laravel 11.11版本发布 - 查看模型中的第三方关系:show

Laravel  /  管理员 发布于 11个月前   736

本周,Laravel团队发布了v11.11,支持模型中的第三方关系:show命令、新的Collection方法、

新的缓存事件等等。


采集前后方法

Ryuta Hamasaki为Collection和LazyCollection实例贡献了before和after方法

以下是pull请求描述中before方法的示例:

$collection = collect([1, 2, 3, 4, 5, 'name' => 'taylor', 'framework' => 'laravel']);
 
$collection->before(2) // 1
$collection->before('taylor') // 5
$collection->before('laravel') // 'taylor'
$collection->before(fn ($value) => $value > 4) // 4
$collection->before(fn ($value) => ! is_numeric($value)) // 5
$collection->before(1) // null
$collection->before('not found') // null


以下是pull请求描述中after方法的示例:

$collection = collect([1, 2, 3, 4, 5, 'name' => 'taylor', 'framework' => 'laravel']);
 
$collection->after(1) // 2
$collection->after('taylor') // 'laravel'
$collection->after(fn ($value) => $value > 4) // 'taylor'
$collection->after(fn ($value) => ! is_numeric($value)) // 'laravel'
$collection->after('laravel') // null
$collection->after('not found') // null


缓存事件

Alex Bouma为应用程序可以监听的框架贡献了新的缓存事件:

use Illuminate\Cache\Events\ForgettingKey;
 
use Illuminate\Cache\Events\KeyForgetFailed;
 
use Illuminate\Cache\Events\KeyWriteFailed;
// Two public properties: `$this->value` and `$this->seconds`
 
use Illuminate\Cache\Events\RetrievingKey;
 
use Illuminate\Cache\Events\RetrievingManyKeys;
// One public property: `$this->keys`
 
use Illuminate\Cache\Events\WritingKey
// Two public properties: `$this->value` and `$this->seconds`
 
use Illuminate\Cache\Events\WritingManyKeys;
// Three public properties:
// `$this->keys`, `$this->values` and `$this->seconds`



支持模型中的第三方关系:show

Jonas Staudenmeir贡献了将第三方包模型关系包括在模型中的能力:show命令:


model:show命令通过分析模型方法的代码并查找$this->hasMany(等)来查找模型的关系。

这不会检测到第三方关系(就像雄辩的hasMany-depth一样)。

我们可以构建一个完整的系统来连接包,但这太过分了,IMO。


相反,我们可以检查方法的返回类型,看看它是否是基类Relation的子类。

不是每个人都使用返回类型,但我希望现在大多数人都这样做。

您可以在拉取请求#51807中了解更多关于此添加的信息。


会话ID获取器

Tim MacDonald为Session facade贡献了Session::id()方法:

Session::id();
 
// You can still use `getId()` too:
Session::getId();



时区和区域设置添加到about命令

Amir Khalife Soltani为Laravel的about命令添加Locale和Timezone值做出了贡献。

现在,您可以通过其他重要的环境信息快速确定配置的区域设置和时区:

1.png


具有“时区”和“区域设置”值的“about”命令

422不可处理的内容状态代码

Dwight Watson对用于确定422状态代码的状态代码方法进行了更新,

该状态代码现在被称为422不可处理内容而不是不可处理实体。

您与断言422状态代码的交互方式没有改变:


$response = $this->postJson('/example', []);
$response->assertUnprocessable();

有关详细信息,请参阅RFC 9110:HTTP语义和拉取请求#51815。


添加关系::getMorphAlias()方法

Dennis Koch贡献了一个Relation::getMorphAlias()方法

由于有一个Relation::getMorphedModel(),我认为添加反向的getMorphAlias是有益的。

此添加对测试特别有益,因为它使用$This->assertDatabaseHas简化了断言。

开发人员不再需要调用所使用的变形别名:


$this->assertDatabaseHas('taskables', [
    'taskable_type' => Relation::getMorphAlias(Document::class),
    'taskable_id' => $mitigation->id,
    'task_id' => $taskB->id
]);



发布说明

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

以下发行说明直接来自更改日志:

https://github.com/laravel/framework/compare/v11.10.0...v11.11.0
https://github.com/laravel/framework/blob/ae63a5b968f764ad0c5ecd86669bcc5fb8be90f7/CHANGELOG.md#v11110---2024-06-18


v11.11.0

[11.x]通过@stayallive在中添加获取、写入和忘记缓存事件
https://github.com/laravel/framework/pull/51560

[11.x]为Arr::sortRecursiveDes()方法添加测试。
由@lmottasin在https://github.com/laravel/framework/pull/51716

[11.x]通过@benholmen在中修复db:table命令中缺少的表名
https://github.com/laravel/framework/pull/51710

确保存在要安装的文件:由@jasonmccrreary在中广播
https://github.com/laravel/framework/pull/51719

[11.x]通过@jessarcher在中恢复异常/错误以测试断言失败消息
https://github.com/laravel/framework/pull/51725

[11.x]@crynobone在中的测试改进
https://github.com/laravel/framework/pull/51723

[11.x]添加可访问的测试,并在中使用@saMahmoudzadeh的方法
https://github.com/laravel/framework/pull/51724

当@yankewei在中添加一些作业时,增加BatchFake的totalJobs属性
https://github.com/laravel/framework/pull/51742

[11.x]通过@timacdonald在中对会话ID检索进行Laravel处理
https://github.com/laravel/framework/pull/51732

[11.x]通过@rookiexxk在splitIn方法中将chunk方法固定为整数类型
https://github.com/laravel/framework/pull/51733

更新:通过@mehdi fathi在中更新名称方法和文档
https://github.com/laravel/framework/pull/51744

[11.x]修复了config:publish,其中@crynobone将dontMergeFrameworkConfiguration()
设置为true
https://github.com/laravel/framework/pull/51751

由@boris-grumbpler在中更新了用于Builder::from()的phpdoc
https://github.com/laravel/framework/pull/51767

[11.x]修复了默认Beankstalkd队列在@rinocs未特别添加时弹出的问题
https://github.com/laravel/framework/pull/51759

[11.x]在中通过@avosalmon将前后方法添加到Collection
https://github.com/laravel/framework/pull/51752

[11.x]通过@jacob418更改afterCreateing和afterMaking回调的范围
https://github.com/laravel/framework/pull/51772

在中由@AmirKhalifehSoltani在文件规则验证中使用数字文字分隔符
https://github.com/laravel/framework/pull/51781

[11.x]在中通过@seriquynh为Renderer\Exception导入模型类
https://github.com/laravel/framework/pull/51778

[11.x]关于@AmirKhalifehSoltani在中的命令改进
https://github.com/laravel/framework/pull/51791

[11.x]在中通过@seriquynh测试中止行为
https://github.com/laravel/framework/pull/51800

[11.x]容器共享固定值/初始化的实例,而不是中@seriquynh的单例闭包解析
https://github.com/laravel/framework/pull/51804

[11.x]修复了在中通过@hafezdivandari更改SQLite上具有默认0列的表的问题
https://github.com/laravel/framework/pull/51803

[11.x]通过@tamiroh修复VendorPublishCommand中的拼写错误
https://github.com/laravel/framework/pull/51812

[11.x]通过@tamiroh在中修复测试中的一些拼写错误
https://github.com/laravel/framework/pull/51811

[11.x]在中通过@dwightwatson添加unprocessableContent并更新unprocessableEntity
https://github.com/laravel/framework/pull/51815

[11.x]改进队列::assertNothingPushed()错误消息,由中的@SjorsO发出
https://github.com/laravel/framework/pull/51814

[11.x]在中通过@pxlrbt添加关系::getMorphAlias()
https://github.com/laravel/framework/pull/51809

[11.x]支持模型中的第三方关系:在中通过@staudenmeir显示命令
https://github.com/laravel/framework/pull/51807

[11.x]通过@owenandrews在中修复嵌套规则自定义属性名称
https://github.com/laravel/framework/pull/51805

[11.x]修复@seriquynh在中的\Illuminate\Http\Response的docblock
https://github.com/laravel/framework/pull/51823


转:

https://laravel-news.com/laravel-11-11-0

  • 上一条:
    在go语言中使用delve调试工具诊断协程泄露流程步骤示例
    下一条:
    在go语言中使用crypto/bcrypt实现用户密码非明文存储示例
  • 昵称:

    邮箱:

    0条评论 (评论内容有缓存机制,请悉知!)
    最新最热
    • 分类目录
    • 人生(杂谈)
    • 技术
    • linux
    • Java
    • php
    • 框架(架构)
    • 前端
    • ThinkPHP
    • 数据库
    • 微信(小程序)
    • Laravel
    • Redis
    • Docker
    • Go
    • swoole
    • Windows
    • Python
    • 苹果(mac/ios)
    • 相关文章
    • Laravel 11.15版本发布 - Eloquent Builder中添加的泛型(0个评论)
    • Laravel 11.14版本发布 - 新的字符串助手和ServeCommand改进(0个评论)
    • Laravel 11.12版本发布 - Artisan的`make`命令自动剪切`.php `扩展(0个评论)
    • Laravel的轻量型购物车扩展包:binafy/laravel-cart(0个评论)
    • Laravel 11.11版本发布 - 查看模型中的第三方关系:show(0个评论)
    • 近期文章
    • 在go+gin中使用"github.com/skip2/go-qrcode"实现url转二维码功能(0个评论)
    • 在go语言中使用api.geonames.org接口实现根据国际邮政编码获取地址信息功能(1个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf分页文件功能(0个评论)
    • gmail发邮件报错:534 5.7.9 Application-specific password required...解决方案(0个评论)
    • 欧盟关于强迫劳动的规定的官方举报渠道及官方举报网站(0个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf文件功能(0个评论)
    • Laravel从Accel获得5700万美元A轮融资(0个评论)
    • 在go + gin中gorm实现指定搜索/区间搜索分页列表功能接口实例(0个评论)
    • 在go语言中实现IP/CIDR的ip和netmask互转及IP段形式互转及ip是否存在IP/CIDR(0个评论)
    • PHP 8.4 Alpha 1现已发布!(0个评论)
    • 近期评论
    • 122 在

      学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..
    • 123 在

      Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..
    • 原梓番博客 在

      在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..
    • 博主 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..
    • 1111 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
    • 2016-10
    • 2016-11
    • 2017-07
    • 2017-08
    • 2020-03
    • 2020-04
    • 2020-05
    • 2020-06
    • 2020-07
    • 2020-08
    • 2020-09
    • 2020-10
    • 2020-11
    • 2021-01
    • 2021-02
    • 2021-03
    • 2021-04
    • 2021-05
    • 2021-06
    • 2021-07
    • 2021-08
    • 2021-09
    • 2021-10
    • 2021-11
    • 2021-12
    • 2022-01
    • 2022-02
    • 2022-03
    • 2022-04
    • 2022-05
    • 2022-06
    • 2022-07
    • 2022-08
    • 2022-09
    • 2022-10
    • 2022-11
    • 2022-12
    • 2023-01
    • 2023-02
    • 2023-03
    • 2023-04
    • 2023-05
    • 2023-06
    • 2023-07
    • 2023-08
    • 2023-09
    • 2023-10
    • 2023-11
    • 2023-12
    • 2024-01
    • 2024-02
    • 2024-03
    • 2024-04
    • 2024-05
    • 2024-06
    • 2024-07
    Top

    Copyright·© 2019 侯体宗版权所有· 粤ICP备20027696号 PHP交流群

    侯体宗的博客