public function create(array $data)
{
// First create the user
$user = create([
'username' => $data['username'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
// Then create the Stats
// (assuming the column with foreign key is called 'user_id')
Stats::create([
'user_id' => $user->id
]);
//Then return the user as before
return $user;
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community