samedi 8 juin 2019

Laravel DB insert([]) only insert first record of array

I have this simple seeder class but for some reason is only inserting the first element from the array and the command is not returning any error.

Im using Laravel 5.8 and postgres as DB engine.

<?php

use Illuminate\Support\Carbon;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

class PermissionsTableSeeder extends Seeder
{
    public function run()
    {
        DB::table('permissions')->insert([
            'id' => 1,
            'name' => 'list_users',
            'display_name' => 'List users',
            'description' => 'Can list all users',
            'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
            'updated_at' => Carbon::now()->format('Y-m-d H:i:s')
        ],
        [
            'id' => 2,
            'name' => 'show_user',
            'display_name' => 'Show single user',
            'description' => 'Can show single user details',
            'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
            'updated_at' => Carbon::now()->format('Y-m-d H:i:s')
        ]);  
    }
}

Result:

enter image description here



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2IsEvUJ
via IFTTT

Aucun commentaire:

Enregistrer un commentaire