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

Laravel 11.3版本发布-laravel提示添加多行文本区域输入

Laravel  /  管理员 发布于 1年前   277

本周,Laravel 团队发布了 v11.3,其中包括 Laravel Prompts 中的多行文本、

Session:hasAny() 方法、Context::pull() 方法等。


多行文本提示

Joe Tannenbaum为 Laravel 提示贡献了一个 textarea 函数,可以接受用户的多行文本:

1.png


Laravel 提示中的多行文本输入

textarea()函数包含一个可选的验证参数和一个必填参数,以确保文本框已填写完毕:

use function Laravel\Prompts\textarea;
 
$story = textarea(
    label: 'Tell me a story.',
    placeholder: 'This is a story about...',
    required: true,
    hint: 'This will be displayed on your profile.'
);
 
// Validation
$story = textarea(
    label: 'Tell me a story.',
    validate: fn (string $value) => match (true) {
        strlen($value) < 250 => 'The story must be at least 250 characters.',
        strlen($value) > 10000 => 'The story must not exceed 10,000 characters.',
        default => null
    }
);

有关用法的详细信息,请参阅textarea()函数文档,

有关实现,请参阅 laravel/prompts 代码库中的Pull Request #88。


新会话 hasAny() 方法

Mahmoud Mohamed Ramadan为会话贡献了hasAny()方法,

这在检查会话中是否有任何值时是一个很好的改进:

// Before
if (session()->has('first_name') || session()->has('last_name')) {
    // do something...
}
 
// Using the new hasAny() method
if (session()->hasAny(['first_name', 'last_name'])) {
    // do something...
}



Context拉取方法

@renegeuze为 Context 服务贡献了pull()和pullHidden()方法,

该方法可提取上下文数据并立即将其从上下文中移除。

$foo = Context::pull('foo');
$bar = Context::pullHidden('foo');

此功能的一个示例用例可能是为数据库日志捕获上下文,并在不再需要额外上下文时将其删除。


发布说明

您可以在 GitHub 上查看以下新功能和更新的完整列表,以及11.2.0 和 11.3.0之间的差异。

以下发布说明直接来自更新日志:

https://github.com/laravel/framework/compare/v11.2.0...v11.3.0
https://github.com/laravel/framework/blob/d63d2b1f50b6bbf8beb88b7b4ad5a4d230244443/CHANGELOG.md#v1130---2024-04-09


v11.3.0

[10.x] 防止队列工作者的 Redis 连接错误报告泛滥
(由@kasus发表于https://github.com/laravel/framework/pull/50812

[11.x] 优化 SetCacheHeaders 以确保错误响应不被缓存
(作者:@MinaWilliam,发布于https://github.com/laravel/framework/pull/50903

[11.x] 添加会话hasAny方法
@mahmoudmohamedramadan发表于https://github.com/laravel/framework/pull/50897

[11.x] 在 ThrottlesExceptions 中间件中添加报告节流异常的选项,
作者@JaZo发布于https://github.com/laravel/framework/pull/50896

[11.x] 添加 DeleteWhenMissingModels 属性
by@Neol3108inhttps://github.com/laravel/framework/pull/50890

[11.x] 允许自定义 TrimStrings::$except
by@grohiroinhttps://github.com/laravel/framework/pull/50901

[11.x] 为 Context 添加拉取方法
by@renegeuzeinhttps://github.com/laravel/framework/pull/50904

[11.x] 删除 MariaDbGrammar 中的冗余代码
@hafezdivandari发布于https://github.com/laravel/framework/pull/50907

[11.x] 明确可空参数声明以修复 PHP 8.4 过时问题
@Jubeki发表于https://github.com/laravel/framework/pull/50922

[11.x] 为缓存存储添加设置器
by@stanclinhttps://github.com/laravel/framework/pull/50912

[10.x] 用于 hasTable 的 Laravel 10x 可选 withSize
by@apspaninhttps://github.com/laravel/framework/pull/50888

[11.x] 修复 artisan 命令中缺少数组参数的提示问题,
作者@macocci7发布于https://github.com/laravel/framework/pull/50850

[11.x] 为 Eloquent 添加严格模式安全的 hasAttribute 方法,
作者@mateusjatenee发布于https://github.com/laravel/framework/pull/50909

[11.x] 添加获取伪造事件的函数
by@browner12inhttps://github.com/laravel/framework/pull/50905

[11.x]retryfunc - catch "Throwable" 而不是 Exception
by@sethsandaruinhttps://github.com/laravel/framework/pull/50944

chore: 删除重复的单词
by@findseatinhttps://github.com/laravel/framework/pull/50943

[10.x] 在NotificationFake中添加serializeAndRestore()
by@dbpolitoinhttps://github.com/laravel/framework/pull/50935

[11.x] 在 HttpClient 重试逻辑中处理 ConnectionException 时防止崩溃
by@shinsenterinhttps://github.com/laravel/framework/pull/50955

[11.x] 删除未知参数
@naopusyu发表于https://github.com/laravel/framework/pull/50965

[11.x] 修复了 PHPDoc[@param](
https://github.com/param)中的错字,
作者@naopusyu发布于https://github.com/laravel/framework/pull/50967

[11.x] 修正 dockblock
by@michaelnabil230inhttps://github.com/laravel/framework/pull/50979

[11.x] 允许在数据库锁中伪造时间
by@JurianArieinhttps://github.com/laravel/framework/pull/50981

[11.x] 引入方法Http::createPendingRequest()
by@Jacobs63inhttps://github.com/laravel/framework/pull/50980

[11.x] 在某些文档块中添加
@throwsby@saMahmoudzadehinhttps://github.com/laravel/framework/pull/50969

[11.x] 修正针对现有视图文件检查的 PHP_MAXPATHLEN 检查,
作者:@joshuaruesweg,收录于https://github.com/laravel/framework/pull/50962

[11.x] 允许从 BelongsToMany 关系中移除作用域
by@plumthedevinhttps://github.com/laravel/framework/pull/50953

[11.x] 如果命名的速率限制器和模型属性不存在,则抛出异常
by@mateusjateneeinhttps://github.com/laravel/framework/pull/50908


转:

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

  • 上一条:
    TIOBE 4月榜单发布-PHP的辉煌不再,排名降至历史最低点!
    下一条:
    PhpStorm 2024.1版本发布,新增集成终端、本地人工智能代码自动完成等功能
  • 昵称:

    邮箱:

    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语言中使用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个评论)
    • Laravel 11.15版本发布 - Eloquent Builder中添加的泛型(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交流群

    侯体宗的博客