blog-google-calendar
blog-google-calendar copied to clipboard
reset() expects parameter 1 to be array, string given
Issue appear on this line: 'name' => head($account->email)->value,
public function store(Request $request, Google $google) { if (! $request->has('code')) { return redirect($google->createAuthUrl()); }
// Use the given code to authenticate the user.
$google->authenticate($request->get('code'));
// Make a call to the Google+ API to get more information on the account.
$account = $google->service('Oauth2')->userinfo->get();
auth()->user()->googleAccounts()->updateOrCreate(
[
// Map the account's id to the `google_id`.
'google_id' => $account->id,
],
[
// Use the first email address as the Google account's name.
'name' => head($account->email)->value,
// Last but not least, save the access token for later use.
'token' => $google->getAccessToken(),
]
);
return redirect()->route('google.index');
}
'name' => $account->email,