I am trying to save my data against my userid but I am getting this error.
My code is:
\App\Keys::create([
$user = \Illuminate\Support\Facades\Auth::user(),
'user_id' => $user,
'accessTokenKey' => $accessTokenKey,
'accessTokenSecret' => $accessTokenSecret
]);
return 'You have successfully granted';
I am getting error user_id does not have a default value and when I passed Auth::user()->id it says trying to get properties of non-object id.
Any help would be appreciated!
Auth::user()->id
only gave you an id if any user logged in! – Hiren Gohel