I've been following a tutorial for 2 hours, and now I have a problem. (Tutorial is using an older version of laravel)
I'm creating a instagram clone, and want to create posts.
Route::post('/p', 'PostsController@store');
That's my web.php
public function store()
{
$data = request()->validate([
'caption' => 'required',
'image' => ['required', 'image'],
]);
auth()->user->posts()->create($data);
dd(request()->all());
}
That's in my PostsController.php
Now, when I want to store a post, I get Undefined property: Illuminate\Auth\AuthManager::$user
How can I fix this?
Thanks in advance