Skip to content
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

Add chain with() feature #29

Merged
merged 1 commit into from
Oct 14, 2020
Merged

Add chain with() feature #29

merged 1 commit into from
Oct 14, 2020

Conversation

ycs77
Copy link
Contributor

@ycs77 ycs77 commented Sep 1, 2020

This PR add can chain use with method feature:

PostPresenter::make($post)
    ->with(function ($post) {
        return [
            'new_key_1' => 'foo',
            'new_key_2' => 'bar',
        ];
    })
    ->with(function ($post) {
        return [
            'new_key_2' => 'baz',
        ];
    })
    ->get();

// Return:
// [
//     'id' => $post->id,
//     'title' => $post->title,
//     'body' => $post->body,
//     'new_key_1' => 'foo',
//     'new_key_2' => 'baz',
// ]

@ycs77 ycs77 changed the title Add chain with feature Add chain with() feature Sep 1, 2020
@fourstacks fourstacks merged commit a0a6d44 into fourstacks:master Oct 14, 2020
@fourstacks
Copy link
Owner

Nice addition, thanks @ycs77 !

@ycs77 ycs77 deleted the chain-with branch October 14, 2020 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants