PHP code example of syropian / laravel-notification-channel-throttling

1. Go to this page and download the library: Download syropian/laravel-notification-channel-throttling 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/ */

    

syropian / laravel-notification-channel-throttling example snippets


use Illuminate\Notifications\Notification;
use Syropian\LaravelNotificationChannelThrottling\Contracts\ThrottlesChannels;

class ExampleNotification extends Notification implements ThrottlesChannels {
    // ...

    public function throttleChannels(object $notifiable, array $channels): array
    {
        /**
         * Throttle the mail channel, so that only one
         * email notification is sent every 15 minutes
         */
        return [
            'mail' => [
                'maxAttempts' => 1,
                'decaySeconds' => 900,
            ],
            'database' => false,
        ];
    }
}

public function __construct(public Post $post) {}

public function throttleChannels(object $notifiable, array $channels): array
{
    return [
        'mail' => [
            'key' => $notifiable->id . ':' . $this->post->id,
            'maxAttempts' => 1,
            'decaySeconds' => 900,
        ],
        'database' => false,
    ];
}