定制 n1215/eloquent-bulk-save 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

n1215/eloquent-bulk-save

最新稳定版本:v0.1.0

Composer 安装命令:

composer require n1215/eloquent-bulk-save

包简介

bulk insert multiple records using Eloquent Model.

README 文档

README

Latest Stable Version

This library contains a trait that enables \Illuminate\Database\Eloquent\Model to bulk insert multiple records in one query. Unlike in the case of directly using \Illuminate\Database\Query\Builder::insert(), this trait method fires each eloquent model events like eloquent.creating, eloquent.saving, and so on.

Usage

// 1. change your eloquent model class to use the trait
class YouModel extends \Illuminate\Database\Eloquent\Model
{
    use \N1215\EloquentBulkSave\BulkInsert;
}

// 2. create model collection (you can also use Illuminate\Database\Eloquent\Collection)
$models = \Illuminate\Support\Collection::make([
    new YourModel($attributes1),
    new YourModel($attributes2),
    ...
]);

// 3. use bulkInsert() static method
YourModel::bulkInsert($models);

License

The MIT License (MIT). Please see LICENSE for more information.

统计信息

  • 总下载量: 22.74k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 9
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 9
  • Watchers: 0
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-07-02