0
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
$image = new Image;
$image->current_step = 'step1';
$image->isCompleted = '0';
$image->save();
}
ユーザーが最初に登録するたびに、別のテーブルにデータの束を入力しようとしています。ユーザーは正常に登録することができますが、データベースをチェックするたびに、他のテーブルには何もありません。ユーザーが登録するたびにデータを追加する - laravel
これは正しい方向に進んでいますか?
protected function create(array $data)
{
$user = User::create([ // <-- HERE
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
$image = new Image;
$image->current_step = 'step1';
$image->isCompleted = '0';
$image->save();
return $user;
}
あなたのコードの残りの部分があるためreturn
の到達不能です:
おかげ
'return'はそれに続くコードの実行を防ぎます。あなたの例では「到達不能」コードと呼ばれるものがあります。 –