【问题标题】:Laravel Eloquent - Inserting multiple recordsLaravel Eloquent - 插入多条记录
【发布时间】:2015-01-18 22:13:40
【问题描述】:

我们如何在 Laravel 中使用 eloquent 插入多条记录?

基本上是这样的:

            Teacher::create([
                'user_id' => $user->id,
                'college_id' => $collegeId,
                'first_name' => $this->faker->firstName(),
                'last_name' => $this->faker->lastName()
            ],[...],[...]);

【问题讨论】:

    标签: laravel eloquent


    【解决方案1】:

    好的,我刚刚遇到了 github 请求,Taylor 回答说 Eloquent 无法使用查询构建器来代替。

    这里是问题的链接:

    https://github.com/laravel/framework/issues/1295

    【讨论】:

    • 是的,但是请注意,您不会获得任何 Eloquent 功能 - 时间戳、事件等。
    猜你喜欢
    • 1970-01-01
    • 2017-03-12
    • 2016-08-16
    • 2015-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多