3 years ago

Append object to a string variable in eloquent

Posted 3 years ago by sbkl


How can I append the $userPosts object to the $Post string variable in the code below?

    Route::get('/test', function(){
        $friends = Auth::User()->friends()->where('status', 'Accepted')->get();

        foreach($friends as $friend){
            $userPosts = $friend->posts()->with('user', 'likes', 'comments.user')->get();
            $posts = $userPosts; 
        return $posts;

Please sign in or create an account to participate in this conversation.