canedoc / laravel-bulk-update
dev-main
2023-06-25 22:10 UTC
Requires
- php: ^8.1
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.0
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2024-09-26 01:10:16 UTC
README
此包向 Laravel Query Builder 添加多行更新功能。它支持 Laravel >= 9。
安装
您可以通过 composer 安装此包。
composer require canedoc/laravel-bulk-update
用法
允许在一个查询中执行多行更新。
在这个例子中,所有具有以下条件的 anime 表中的行:1- 电子邮件 = 'aruto@best.com' 和名字 = 'naruto' 的年龄将被设置为 33。2- 'name' = 'sasuki' 的电子邮件将被设置为 'sasuki@best.com' 3- 所有行的 is_alive 将被设置为 true
$data = [ 'age' => [ ['email' => 'naruto@best.com', 'name' => 'naruto', 'age' => 33], ], 'email' => ['email' => 'sasuki@best.com', 'name' => 'sasuki'], 'is_alive' => true ] \DB::table('animes')->where('is_active', true)->bulkUpdate($data); Animes::where('is_active', true)->bulkUpdate($data);
测试
composer test
贡献
请参阅 CONTRIBUTING 以获取详细信息。
安全漏洞
请查看 我们的安全策略 了解如何报告安全漏洞。
鸣谢
许可
MIT 许可证 (MIT)。请参阅 许可文件 以获取更多信息。