PHP code example of petecoop / gotify

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

    

petecoop / gotify example snippets


'gotify' => [
    'url' => env('GOTIFY_URL', 'https://gotify.example.com'),
    'token' => env('GOTIFY_TOKEN'),
],

use Petecoop\Gotify\Facades\Gotify;

Gotify::message('Version 2 is live.')
    ->title('Deployment complete')
    ->highPriority()
    ->send();

Gotify::message('Version 2 is live.')
    ->title('Deployment complete')
    ->queue();

Gotify::message('Version 2 is live.')
    ->queue(connection: 'redis', queue: 'developer-alerts');

use Petecoop\Gotify\GotifyMessage;
use Illuminate\Notifications\Notification;

class AccountApproved extends Notification
{
    public function via(object $notifiable): array
    {
        return ['gotify'];
    }

    public function toGotify(object $notifiable): GotifyMessage
    {
        return GotifyMessage::make('The invoice has been paid.')
            ->title('Invoice paid')
            ->lowPriority()
            ->url('http://example.com/invoices');
    }
}

use Illuminate\Notifications\Notification;

// On your User model (or another notifiable model)
public function routeNotificationForGotify(Notification $notification): string|false|null
{
    return $this->receives_gotify_notifications
        ? $this->gotify_token
        : false;
}

public function routeNotificationForGotify(Notification $notification): array
{
    return [
        'url' => $this->gotify_url,
        'token' => $this->gotify_token,
    ];
}