Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze authored Oct 20, 2022
1 parent fdfc512 commit dcaad3e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ User::flagged('myFlag')->get(); // returns all models with the given flag
User::notFlagged('myFlag')->get(); // returns all models without the given flag
```

Though there are other usages, the primary use case of this package is to easily build idempotent (aka restartable) pieces of code. Image you should write an artisan command that sends a mail to each user. Using flags, you can make sure that if the command is cancelled half-way, that in the second invocation, you'll only send mails to users that haven't received one yet.
Though there are other usages, the primary use case of this package is to easily build idempotent (aka restartable) pieces of code. Image you should write an Artisan command that sends a mail to each user. Using flags, you can make sure that if the command is cancelled half-way, that in the second invocation, you'll only send mails to users that haven't received one yet.

```php
// in an artisan command
// in an Artisan command

User::notFlagged('hasReceivedExtraMail')
->each(function(User $user) {
Expand All @@ -36,6 +36,8 @@ User::notFlagged('hasReceivedExtraMail')
});
```

No matter how many times you would execute this command, users would only get the mail once.

## Support us

[<img src="https://github-ads.s3.eu-central-1.amazonaws.com/laravel-model-flags.jpg?t=1" width="419px" />](https://spatie.be/github-ad-click/laravel-model-flags)
Expand Down

0 comments on commit dcaad3e

Please sign in to comment.