Level 39
It appears that you don't have an authenticated user. What do you get when you run dd(Auth::user);?
2 likes
Hi fellow artisans, this error "Attempt to read property "id" on null" keeps popping up when I try to store my data in the database, this is my controller.
public function store(Request $request){ $request->validate([ 'title' => 'required', 'image' => 'required | image', 'body' => 'required' ]);
$title = $request->input('title');
$slug = Str::slug($title, '-');
$user_id = Auth::user()->id;
$body = $request->input('body');
// file upload
$request->file('image')->store('public');
dd('validation successful');
It appears that you don't have an authenticated user. What do you get when you run dd(Auth::user);?
Please or to participate in this conversation.