How to maintain load relationships for one eloquent object?
I have this model Comment
with attitude.
class Comment extends Model
{
public function user()
{
return $this->belongsTo('App\User');
}
}
In my controller:
public function store(Request $request)
{
$comment = $this->dispatch(
new StoreCommentCommand($request->body, Auth::user()->id, $request->post_id)
);
return $comment;
}
When I return $comment
I also want a nested user object, how can I do that?
+3
source to share
2 answers