Laravel 返回错误的数据库列名以保存数据

Dol*_*rma -1 php laravel laravel-5.6

在 Laravel 迁移中,我有这一行:

$table->tinyInteger('action_type')->index();
Run Code Online (Sandbox Code Playgroud)

当我尝试使用以下代码将数据保存在表中时:

ActionsLog::create([
    'account_id' => auth()->user()->id,
    'action_type' => 1,  //like
    'log', $ex->getMessage()
]);
Run Code Online (Sandbox Code Playgroud)

laravel 无法返回该名称所在的第三列,action_type我收到此错误:

Column not found: 1054 Unknown column '1' in 'field list' (SQL: insert into `actions_logs` (`account_id`, `action_type`, `1`, `updated_at`, `created_at`) values (2, 1, SQLSTATE[42S22]: Column not found: 1054 Unknown column '1' in 'field list' (SQL: insert into `actions_logs` (`account_id`, `action_type`, `1`, `updated_at`, `created_at`) values (2, 1, Use of undefined constant ture - assumed 'ture' (this will throw an Error in a future version of PHP), 2018-07-11 07:50:18, 2018-07-11 07:50:18)), 2018-07-11 07:50:18, 2018-07-11 07:50:18))
Run Code Online (Sandbox Code Playgroud)

我的迁移文件:

public function up()
{
    Schema::create('actions_logs', function (Blueprint $table) {
        $table->increments('id');
        $table->integer('account_id')->unsigned();
        $table->foreign('account_id')->references('id')->on('instagram_actions_histories')->onDelete('cascade');
        $table->tinyInteger('action_type')->index();
        $table->text('log');
        $table->timestamps();
    });
}
Run Code Online (Sandbox Code Playgroud)

Lov*_*ngh 5

问题出在 line 上'log', $ex->getMessage(),将此行更改为=>. 替换代码为:

ActionsLog::create([
    'account_id' => auth()->user()->id,
    'action_type' => 1,
    'log' => $ex->getMessage()
]);
Run Code Online (Sandbox Code Playgroud)

  • 'log' => $ex->getMessage() ------- 'log', $ex->getMessage()。在第一个键 => 值中,在第二个值中,值 (2认同)