vendredi 2 octobre 2015

Applying more query conditions after calling function

If I have something like:

$users = Helpers::getUsersFollowing($user_id);

Where getUsersFollowing() looks like this:

public static function getUsersFollowing($user_id)
{
    return Follow::where('user_id', $user_id)
        ->select('username')
        ->get();
}

Is it possible to, without modifying the code in the function, apply more queries after the function call, like:

$users = Helpers::getUsersFollowing($user_id)
    ->with('posts')
    ->select('display_name')
    ->get();

I need to be able to select the display names (in addition to the usernames) and get the user's posts as well, but again, without modifying the code in the function.

How can I do this?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire