小编Jon*_*n D的帖子

类型错误:传递给 Illuminate\Database\Grammar::parameterize() 的参数 1 必须是数组类型,给定整数

我正在使用 Laravel 工厂来为我的数据库做种,但我不明白为什么会抛出这个错误。(显示在底部)。

这是我的第一篇文章,所以请让我知道我如何能够更清楚地描述问题:)

PollAnswerFactory.php

$factory->define(PollAnswer::class, function (Faker\Generator $faker) {

    $answer_text = $faker->word;
    $answer_order = rand(0,10);
    $question_id = rand(1,500);

    return [
        "answer_text" => $answer_text,
        "answer_order" => $answer_order,
        "question_id" => $question_id,
    ];
});
Run Code Online (Sandbox Code Playgroud)

PollAnswer.php

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class PollAnswer extends Model {

    /**
     * @var bool Indicates if the model should be timestamped.
     */
    public $timestamps = false;

    /**
     * @var string The database table for this model.
     */
    protected $table = 'poll_answers';

    /**
     * The connection name …
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-5

1
推荐指数
1
解决办法
3771
查看次数

标签 统计

laravel ×1

laravel-5 ×1

php ×1