PHP code example of befuturein / scheduled-reminders

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

    

befuturein / scheduled-reminders example snippets


return [
    'default_channel' => 'email',

    'channels' => [
        'email',
        'database',
        'sms',
    ],

    'run_interval_minutes' => 5,
];

// app/Console/Kernel.php

protected function schedule(\Illuminate\Console\Scheduling\Schedule $schedule): void
{
    $schedule->command('scheduled-reminders:send')->everyMinute();
}

use BeFuture\ScheduledReminders\Services\ReminderService;

$reminder = app(ReminderService::class)->create([
    'title'        => 'Payment Reminder',
    'message'      => 'Please don’t forget your monthly payment.',
    'channel'      => 'email',
    'scheduled_at' => now()->addMinutes(10),
]);

$due = app(ReminderService::class)->dueReminders();

app(ReminderService::class)->markAsSent($reminder);

BeFuture\ScheduledReminders\Events\ReminderSent

class LogReminderSent
{
    public function handle(ReminderSent $event)
    {
        logger('Reminder sent', [
            'id' => $event->reminder->id,
        ]);
    }
}

abstract class TestCase extends BaseTestCase
{
    use RefreshDatabase;

    protected function getPackageProviders($app): array
    {
        return [
            ScheduledRemindersServiceProvider::class,
        ];
    }

    protected function defineDatabaseMigrations()
    {
        $this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
    }
}
bash
php artisan vendor:publish --tag=scheduled-reminders-config
php artisan vendor:publish --tag=scheduled-reminders-migrations
php artisan migrate