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 Conditionable to ActivityLogger #997

Merged
merged 1 commit into from
Apr 7, 2022
Merged

Add Conditionable to ActivityLogger #997

merged 1 commit into from
Apr 7, 2022

Conversation

usernotnull
Copy link
Contributor

This PR adds Conditionable trait.

activity()
    ->by($comment->commented)
    ->on($comment->commentable)
    ->when(
        $condition,
        fn (ActivityLogger $logger) => $logger->chainSomething()
    )
    ->when(
        $anotherCondition,
        fn (ActivityLogger $logger) => $logger->chainSomethingElse()
    )
    ->log('comment.created');

The above would be a tidy implementation of something that could get more ugly as more conditions are added.

adds `Conditionable` trait
@Gummibeer
Copy link
Collaborator

Gummibeer commented Feb 5, 2022

I like it very much @freekmurze could you release it. Will stop GitHub for today now.

https://gummibeer.dev/blog/2022/end-of-an-era/

@AlexVanderbist
Copy link
Member

hey @usernotnull, thanks for your patience and thanks for the great PR. Small change but very useful indeed :D

@AlexVanderbist AlexVanderbist merged commit 74ad9bd into spatie:main Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants