PHP code example of gsouillard / laravel-new-user-slack-notifier

1. Go to this page and download the library: Download gsouillard/laravel-new-user-slack-notifier 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/ */

    

gsouillard / laravel-new-user-slack-notifier example snippets


return [
    'webhook_url' => env('SLACK_NEW_USER_NOTIFIER_WEBHOOK_URL', ''),
    'app_name' => env('APP_NAME', 'Your Application'), // Default: APP_NAME
    'event_to_listen' => env('SLACK_NEW_USER_NOTIFIER_EVENT', 'Registered'), // Default: Registered
];

use YourNamespace\SlackNotifier\SlackNotifier;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Events\Verified;
use Illuminate\Support\Facades\Event;

class EventServiceProvider extends ServiceProvider
{
    public function boot()
    {
        parent::boot();

        $eventToListen = config('slack-new-user-notifier.event_to_listen', 'Registered');

        if ($eventToListen === 'Verified') {
            Event::listen(Verified::class, function ($event) {
                SlackNotifier::notify($event->user->email);
            });
        } else {
            Event::listen(Registered::class, function ($event) {
                SlackNotifier::notify($event->user->email);
            });
        }
    }
}

php artisan vendor:publish --tag=config