Аргумент 1, передаваемый в Illuminate \ Database \ Query \ Builder :: insert (), должен иметь тип массива, значение NULL - PullRequest
0 голосов
/ 02 мая 2019

Добрый день,

У меня есть проблема, которую я тралял уже несколько дней и, похоже, не могу разобраться. Просто интересно, может ли кто-нибудь, пожалуйста, указать мне в правильном направлении. Я использую : - Laravel Версия: 5.8. - Версия PHP: 7.2.5 - Драйвер базы данных и версия: MySQL Есть предложения, что я делаю не так? Я ценю ваши ответы!

StackTrace:

Symfony\Component\Debug\Exception\FatalThrowableError  : Argument 1 passed to Illuminate\Database\Query\Builder::insert() must be of the type array, null given, called in C:\xampp\htdocs\Laravel\crm\database\migrations\2018_07_18_054859_create_counters_table.php on line 28 at C:\xampp\htdocs\Laravel\crm\vendor\laravel\framework\src\Illuminate\Database\Query\Builder.php:2611
    2607|      *
    2608|      * @param  array  $values
    2609|      * @return bool
    2610|      */
  > 2611|     public function insert(array $values)
    2612|     {
    2613|         // Since every insert gets treated like a batch insert, we will make sure the
    2614|         // bindings are structured in a way that is convenient when building these
    2615|         // inserts statements by verifying these elements are actually an array.

  Exception trace:

  1   Illuminate\Database\Query\Builder::insert()
      C:\xampp\htdocs\Laravel\crm\database\migrations\2018_07_18_054859_create_counters_table.php:28

  2   CreateCountersTable::load()
      C:\xampp\htdocs\Laravel\crm\database\migrations\2018_07_18_054859_create_counters_table.php:23

  Please use the argument -v to see more details.

Это мой код 018_07_18_054859_create_counters_table.php

<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCountersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('counters', function (Blueprint $table) {
            $table->increments('id');
            $table->string('key')->unique();
            $table->string('prefix')->unique();
            $table->integer('value');
            $table->timestamps();
        });
        $this->load();
    }

    protected function load()
    {
        DB::table('counters')->insert(config('crm.counters'));
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('counters');
    }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...