https://github.com/spatie/laravel-notification-log
Log notifications sent by your Laravel app
https://github.com/spatie/laravel-notification-log
history laravel notification php
Last synced: 2 months ago
JSON representation
Log notifications sent by your Laravel app
- Host: GitHub
- URL: https://github.com/spatie/laravel-notification-log
- Owner: spatie
- License: mit
- Created: 2023-02-23T07:40:29.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-22T07:44:07.000Z (3 months ago)
- Last Synced: 2025-04-22T08:42:40.593Z (3 months ago)
- Topics: history, laravel, notification, php
- Language: PHP
- Homepage: https://spatie.be/docs/laravel-notification-log
- Size: 147 KB
- Stars: 188
- Watchers: 3
- Forks: 16
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
- Support: docs/support-us.md
Awesome Lists containing this project
README
# Log notifications sent by your Laravel app
[](https://packagist.org/packages/spatie/laravel-notification-log)
[](https://github.com/spatie/laravel-notification-log/actions?query=workflow%3Arun-tests+branch%3Amain)
[](https://github.com/spatie/laravel-notification-log/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[](https://packagist.org/packages/spatie/laravel-notification-log)This package will log all the notifications sent by your app. This will allow you to write logic based on the notifications your app has sent.
If you want to create a list of all notifications sent to a user
```php
// returns a collection of `NotificationLogItem` models
$sentNotifications = $user->loggedNotifications();
```In a view, you could write this:
```blade
- {{ $sentNotification->type }} at {{ $sentNotification->created_at->format('Y-m-d H:i:s') }}
@foreach($sentNotifications as $sentNotification)
@endforeach
```
The package also contains handy methods that allow you to make decisions based on the notifications sent. Here's an example, where we use the `wasAlreadySentTo` method provided by the package in a `shouldSent` method of a notification.
```php
// in a notification
public function shouldSend($notifiable)
{
return ! $this
->wasAlreadySentTo($notifiable)
->inThePastMinutes(60);
}
```
You can fully customize which notifications get logged and how they get logged.
## Support us
[](https://spatie.be/github-ad-click/laravel-notification-log)
We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).
## Documentation
All documentation is available [on our documentation site](https://spatie.be/docs/laravel-notification-log).
## Testing
```bash
composer test
```
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.
## Security Vulnerabilities
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
## Credits
- [Freek Van der Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.