Laravel - Model :: create或Model-> save()上的数组到字符串转换错误

haa*_*kym 6 php laravel eloquent

我正在执行一个简单的插入,我已经做了很多次没有任何问题,并且由于一些奇怪的原因,它不起作用,我收到此错误消息:

error: {type: "ErrorException", message: "Array to string conversion",…}
file: "C:\wamp\www\studentreg2\vendor\laravel\framework\src\Illuminate\Database\Grammar.php"
  line: 33
  message: "Array to string conversion"
  type: "ErrorException"
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

$advisorCheck = AdvisorCheck::create([
            'status'         => Input::get('status'),
            'application_id' => Input::get('id'),
            'user_id'        => Auth::id()
        ]);
Run Code Online (Sandbox Code Playgroud)

AdvisorCheck模型使用的advisor_check表的迁移似乎很好,所有外键都是无符号的并且在phpmyadmin中正确显示关系,Input :: get中的所有值都是字符串,模型将正确的字段设置为fillable(status,application_id , 用户身份).

我甚至试过这样做php artisan tinker:

AdvisorCheck::create([ 'status' => 'returned', 'application_id' => '3', 'user_id' => '4']);
Run Code Online (Sandbox Code Playgroud)

我得到这个回应:数组到字符串转换

我也试过这个方法并得到同样的错误:

$advisorCheck                 = new AdvisorCheck;
$advisorCheck->status         = Input::get('status');
$advisorCheck->application_id = Input::get('id');
$advisorCheck->user_id        = Auth::id();
$advisorCheck->save();
Run Code Online (Sandbox Code Playgroud)

型号代码:

<?php

class AdvisorCheck extends \Eloquent {

    protected $fillable = ['status', 'application_id', 'user_id'];

    protected $table = ['advisor_check'];
}
Run Code Online (Sandbox Code Playgroud)

如果您需要查看更多代码,请询问.

非常感谢任何可以提供帮助的人!

luk*_*ter 16

正如您在Laravel文档中显示的示例中所看到的,table属性是字符串而不是数组

protected $table = 'advisor_check';
Run Code Online (Sandbox Code Playgroud)

如果你考虑它,这是完全有道理的,因为Eloquent模型本身不支持多个表.