I have changed the default unsigned integer id of User table to uuid or char(36). For it to automatically generate Uuid during saving of new user, I have changed the register function in RegistersUsers trait to as -
public function register(Request $request)
{
$validator = $this->validator($request->all());
if ($validator->fails()) {
$this->throwValidationException(
$request, $validator
);
}
$inputsArray=$request->all();
$inputsArray['id']=(string)Uuid::generate();
//dd($inputsArray);
Auth::guard($this->getGuard())->login($this->create($inputsArray));
return redirect($this->redirectPath());
}
Finally, it saves the new user data but with blank id column. I thought the uuid is not generated but when I dumped $inputsArray there was id value with 36 chars. Help me understand this, to save the data with user id. Thanks.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire