I'm trying to get the current user through User model but it returns null.
$user = new User;
//$user = Auth::user();
$product = new Product;
$product->user_id = $user->user_id;
$product->save();
This is what I get Integrity constraint violation: 1048 Column 'user_id' cannot be null
When I tried to get it with Auth::user(), it gives same error.
What's wrong with this code?
via ishan shah