#laravel-8 #laravel-seeding
Вопрос:
Я пытаюсь заполнить три таблицы, но я запускаю команду
база данных php artisan:seed
затем столкнулся с этой ошибкой
SQLSTATE[42S22]: Столбец не найден: 1054 Неизвестный столбец «идентификатор пользователя» в «списке полей» (SQL: вставить в
doctors
(user_id
, ,first_name
,last_name
,address
,gender
,contact_number
,prof_degree
,department
) значения (7, Доктор, Афлатон, abc, мужчина, 123456789, 1, 1))
мой код предназначен для посева
сеялка пользователя
public function run()
{
DB::table('users')->insert([
'user_type' => 'doctor',
'email' => 'doctor@gmail.com',
'email_verified_at' => now(),
'password' => Hash::make('doctor_1234'),
// 'approved_at' => now(),
'created_at' => now(),
'updated_at' => now(),
]);
DB::table('users')->insert([
'user_type' => 'patient',
'email' => 'patient@gmail.com',
'email_verified_at' => now(),
'password' => Hash::make('patient_1234'),
// 'approved_at' => now(),
'created_at' => now(),
'updated_at' => now(),
]);
}
доктор сеялка
public function run()
{
DB::table('doctors')->insert([
'user_id ' => User::where('user_type','doctor')->first()->id,
'first_name' => 'Doctor',
'last_name' => 'Aflaton' ,
'address' => 'abc',
'gender' => 'male',
'contact_number ' => '123456789',
'prof_degree' => '1',
'department' => '1',
]);
}
и терпеливая сеялка
public function run()
{
DB::table('patients')->insert([
'user_id ' => User::where('user_type','patient')->first()->id,
'first_name' => 'patient',
'last_name' => 'Patient',
'address' => 'abc',
'gender' => 'male',
'contact_number' => '123456789',
]);
}
я не знаю, в чем проблема.