Level 5
Hello @jesse_orange_newable ,
Please visit this guide.
Also, you can refer laravel-testing-authencation-flow
In an application I'm building a Comment can have a relation to both a User and an Article, so when creating the comment I just do the following:
$article->comments()->create($request->validated());
Then to associate the User I hook into the creating event of the Comment model to associate the user with the comment like so:
$comment->user()->associate(auth()->user());
However, in my test case it always squawks about comment user_id being null, which leads me to believe that in the test case auth()->user() is null.
How can this be so when I'm using actingAs() when calling the route to add the comment?
Please or to participate in this conversation.