New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy undefined query builder method calls to the results collection #20749

Merged
merged 1 commit into from Aug 25, 2017

Conversation

Projects
None yet
2 participants
@phroggyy
Contributor

phroggyy commented Aug 25, 2017

This PR makes the QB ever so slightly easier to use, by proxying all unknown method calls to the results collection (from calling get). This means that:

DB::select('*')
    ->from('users')
    ->get()
    ->map(function ($user) {
        $user = (array) $user;
        $user['name'] = $user['first_name'].' '.$user['last_name'];

        return $user;
    });

becomes

DB::select('*')
    ->from('users')
    ->map(function ($user) {
        $user = (array) $user;
        $user['name'] = $user['first_name'].' '.$user['last_name'];

        return $user;
    });

Yes, it's a small thing, but it's a convenience I believe people will find useful.

@taylorotwell

This comment has been minimized.

Show comment
Hide comment
@taylorotwell

taylorotwell Aug 25, 2017

Member

This thought has definitely crossed my mind. Will look it over.

Member

taylorotwell commented Aug 25, 2017

This thought has definitely crossed my mind. Will look it over.

@taylorotwell taylorotwell merged commit 446245e into laravel:master Aug 25, 2017

2 checks passed

continuous-integration/styleci/pr The StyleCI analysis has passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@taylorotwell

This comment has been minimized.

Show comment
Hide comment
@taylorotwell

taylorotwell Aug 25, 2017

Member

Reverted. Doesn't work with Eloquent.

Member

taylorotwell commented Aug 25, 2017

Reverted. Doesn't work with Eloquent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment