I have two models Poll and DuplicatePoll
with the respective tables:
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');
});
when i go to create a value for DuplicatePolls with tinker i get the following error:
App\Models\DuplicatePoll::factory()->create(['poll_id'=>10]); PHP Fatal error: Class 'App/Models/DuplicatePoll' not found in Psy Shell code on line 1
in the DuplicatePoll factory:
<?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(),
];
}
}
UPDATE:
i ran a composer-dump autoload and now i get the error:
App\Models\DuplicatePoll::factory()->create(['poll_id'=>10]);
Illuminate/Database/QueryException with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'updated_at' in 'field list' (SQL: insert into duplicate_polls
(poll_id
, updated_at
, created_at
) values (10, 2020-11-19 11:49:32, 2020-11-19 11:49:32))'