Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.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
Laravel8x:don';t使用工厂的轮询id创建FK_Laravel_Factory_Laravel 8_Tinker - Fatal编程技术网

Laravel8x:don';t使用工厂的轮询id创建FK

Laravel8x:don';t使用工厂的轮询id创建FK,laravel,factory,laravel-8,tinker,Laravel,Factory,Laravel 8,Tinker,我有两个模型Poll和DuplicatePoll 各表如下: Schema::create('polls', function (Blueprint $table) { $table->id(); $table->text('status'); $table->timestamps(); }); Schema::create('duplicate_polls', function (Blueprin

我有两个模型Poll和DuplicatePoll

各表如下:

Schema::create('polls', function (Blueprint $table) {
        $table->id();           
        $table->text('status');
        $table->timestamps();
    });

Schema::create('duplicate_polls', function (Blueprint $table) {
        $table->id();
        $table->unsignedBigInteger('poll_id');
        $table->timestamp('created_at')->useCurrent();

        $table->foreign('poll_id')
        ->references('id')
        ->on('polls');
    });
当我使用tinker为DuplicatePolls创建值时,会出现以下错误:

App\Models\DuplicatePoll::factory()->create(['poll\u id'=>10]); PHP致命错误:在第1行的Psy Shell代码中未找到类“App/Models/DuplicatePoll”

在重复投票工厂中:

    <?php

namespace Database\Factories;

use App\Models\DuplicatePoll;
use App\Models\Poll;

use Illuminate\Database\Eloquent\Factories\Factory;

class DuplicatePollFactory extends Factory
{
    /**
     * The name of the factory's corresponding model.
     *
     * @var string
     */
    protected $model = duplicatePoll::class;

    /**
     * Define the model's default state.
     *
     * @return array
     */
    public function definition()
    {
        return [
                'poll_id' => Poll::factory()->create(),
        ];
    }
}

如果在
字段中没有更新的
,则必须将模型配置为不自动使用该时间戳字段,您指的是哪种模型?可以举个例子吗?