pretty new to Laravel and still kind of a noob at PHP. Following along with a tutorial. I have a model named User.php that creates a public function.
public function posts(){
return $this->hasMany(Post::class);
}
And so I'm referencing it in my controller as such:
auth()->user()->posts()->create($data);
But it's giving me this error saying "Undefined method 'posts'. intelephense(1013) [19,29]"
Why is it undefined, from what I understand a public function should be accessible right? Any help? Thanks.