Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel-模型::创建或模型->;上的数组到字符串转换错误;保存()_Php_Laravel_Eloquent - Fatal编程技术网

Php Laravel-模型::创建或模型->;上的数组到字符串转换错误;保存()

Php Laravel-模型::创建或模型->;上的数组到字符串转换错误;保存(),php,laravel,eloquent,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 t

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

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"
这是我的密码:

$advisorCheck = AdvisorCheck::create([
            'status'         => Input::get('status'),
            'application_id' => Input::get('id'),
            'user_id'        => Auth::id()
        ]);
AdvisorCheck模型使用的advisor_检查表的迁移似乎很好,所有外键都是无符号的,并且在phpmyadmin中正确显示了关系,Input::get中的所有值都是字符串,模型将正确的字段设置为可填充(status、application_id、user_id)

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

AdvisorCheck::create([ 'status' => 'returned', 'application_id' => '3', 'user_id' => '4']);
我得到的回答是: 数组到字符串的转换

我也尝试过这种方法,但得到了相同的错误:

$advisorCheck                 = new AdvisorCheck;
$advisorCheck->status         = Input::get('status');
$advisorCheck->application_id = Input::get('id');
$advisorCheck->user_id        = Auth::id();
$advisorCheck->save();
型号代码:

<?php

class AdvisorCheck extends \Eloquent {

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

    protected $table = ['advisor_check'];
}

正如您在表中所示的示例中所看到的,表属性是一个字符串,而不是一个数组

protected $table = 'advisor_check';

仔细想想,这是完全有道理的,因为雄辩的模型不支持本地多个表。

$table
应该是字符串而不是数组

<?php

   class AdvisorCheck extends \Eloquent {

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

   protected $table = 'advisor_check';
}

这个模型有什么与众不同的地方吗?我有一种感觉,这是因为我把$table放在$filleble之前,我所有的其他模型都是先有$filleble的-现在试一试没有,不是吗-我想这没有任何意义吧?我将发布模型代码
属性必须是字符串而不是数组@卢卡斯盖特是个好地方。