PHP code example of coderello / laravel-relevance-ensurer

1. Go to this page and download the library: Download coderello/laravel-relevance-ensurer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

coderello / laravel-relevance-ensurer example snippets


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



namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification; 
use Illuminate\Contracts\Queue\ShouldQueue;
use Coderello\RelevanceEnsurer\Contracts\ShouldBeRelevantNotification;
use App\Models\Meetup;
use Illuminate\Queue\SerializesModels;

class MeetingReminder extends Notification implements ShouldQueue, ShouldBeRelevantNotification
{
    use Queueable, SerializesModels;

    public $meetup;

    public function __construct(Meetup $meetup)
    {
        $this->meetup = $meetup;
    }

    public function isRelevant($notifiable): bool
    {
        return $this->meetup->users()->where('id', $notifiable)->exists();
    }

    public function toMail($notifiable)
    {
        // returns the mail representation of the notification
    }
}