PHP code example of thomasjohnkane / snooze

1. Go to this page and download the library: Download thomasjohnkane/snooze 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/ */

    

thomasjohnkane / snooze example snippets


use Thomasjohnkane\Snooze\Traits\SnoozeNotifiable;
use Illuminate\Notifications\Notifiable;

class User extends Model {
    use Notifiable, SnoozeNotifiable;

    // ...
}

// Schedule a birthday notification
$user->notifyAt(new BirthdayNotification, Carbon::parse($user->birthday));

// Schedule for a week from now
$user->notifyAt(new NextWeekNotification, Carbon::now()->addDays(7));

// Schedule for new years eve
$user->notifyAt(new NewYearNotification, Carbon::parse('last day of this year'));

ScheduledNotification::create(
     Auth::user(), // Target
     new ScheduledNotificationExample($order), // Notification
     Carbon::now()->addHour() // Send At
);

$target = (new AnonymousNotifiable)
    ->route('mail', '[email protected]')
    ->route('sms', '56546456566');

ScheduledNotification::create(
     $target, // Target
     new ScheduledNotificationExample($order), // Notification
     Carbon::now()->addDay() // Send At
);

$notification->cancel();

$rescheduleAt = Carbon::now()->addDay(1)

$notification->reschedule($rescheduleAt)

$notification->scheduleAgainAt($newDate); // Returns the new (duplicated) $notification

// Check if a notification is already cancelled

$result = $notification->isCancelled(); // returns a bool

// Check if a notification is already sent

$result = $notification->isSent(); // returns a bool

public function shouldInterrupt($notifiable) {
    return $notifiable->isInactive() || $this->order->isCanceled();
}

ScheduledNotification::create(
     $target, // Target
     new ScheduledNotificationExample($order), // Notification
     Carbon::now()->addDay(), // Send At,
     ['foo' => 'bar'] // Meta Information
);

  $user->notifyAt(new BirthdayNotification, Carbon::parse($user->birthday), ['foo' => 'bar']);

  ScheduledNotification::findByMeta('foo', 'bar'); //key and value
bash
php artisan migrate
bash
php artisan vendor:publish --provider="Thomasjohnkane\Snooze\ServiceProvider" --tag="config"