I am using laravel auth to handle my login/register/validation etc. Now i need to after creating the user at register also create another table containing the user->id.
Something like this is what i would like to achieve, obviously this doesnt work but you get what im after. Is this possible or is my only option to create a custom registercontroller for my needs?
class RegisterController extends Controller
{
use RegistersUsers;
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\User && \App\Stats
*/
protected function create(array $data)
{
return [
User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]),
Stats::create([
'user_id' => $user->id
])
];
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire