PHPackages                             coderello/laravel-relevance-ensurer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. coderello/laravel-relevance-ensurer

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

coderello/laravel-relevance-ensurer
===================================

Laravel Relevance Ensurer

0.4.0(5y ago)524.1k3MITPHP

Since Feb 18Pushed 5y ago2 watchersCompare

[ Source](https://github.com/coderello/laravel-relevance-ensurer)[ Packagist](https://packagist.org/packages/coderello/laravel-relevance-ensurer)[ RSS](/packages/coderello-laravel-relevance-ensurer/feed)WikiDiscussions 1.0 Synced yesterday

READMEChangelog (5)Dependencies (4)Versions (7)Used By (0)

[![Laravel Relevance Ensurer](https://camo.githubusercontent.com/0317f6e5ea8a8039dad72c6fdd3c0d14dc1a4f40c69ad854d94cc2522228fa2e/68747470733a2f2f636f646572656c6c6f2e636f6d2f696d616765732f7061636b616765732f6c61726176656c2d72656c6576616e63652d656e73757265722e706e67)](https://camo.githubusercontent.com/0317f6e5ea8a8039dad72c6fdd3c0d14dc1a4f40c69ad854d94cc2522228fa2e/68747470733a2f2f636f646572656c6c6f2e636f6d2f696d616765732f7061636b616765732f6c61726176656c2d72656c6576616e63652d656e73757265722e706e67)

**Laravel Relevance Ensurer** provides an easy way not to process notifications and jobs which became irrelevant.

Install
-------

[](#install)

You can install this package via composer using this command:

```
composer require coderello/laravel-relevance-ensurer
```

Usage
-----

[](#usage)

Let's assume we are a meetup organizing platform. And we have to remind all participants of the meetup 48 hours before it starts.

Huh, looks like it is easy. Few lines of code.

```
$user->notify(
    (new MeetupReminder($meetup))
        ->delay($meetup->starts_at->subHours(48))
);
```

But what if the user leaves the meetup? In this case, we should prevent the notification from being sent.

Here **Laravel Relevance Ensurer** comes to help.

The only thing we need to do is to implement `ShouldBeRelevantNotification` contract on the notification. It comes with one public method `isRelevant($notifiable)` which should return bool representing relevance of the notification before one is sent.

Let's take a look at an example:

```
