PHP code example of connectmedia / laravel

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

    

connectmedia / laravel example snippets


use ConnectMedia\Laravel\Facades\ConnectMedia;

ConnectMedia::send('0712345678', 'Your order has shipped.');

// Several recipients, a different sender ID and a scheduled time
ConnectMedia::send(['0712345678', '0733000111'], 'Fees are due on Friday.', [
    'sender'     => 'YourSchool',
    'scheduleAt' => now()->addDay()->setTime(9, 0),
]);

ConnectMedia::balance();
ConnectMedia::history(limit: 20);
ConnectMedia::inbox();

use ConnectMedia\Laravel\ConnectMediaMessage;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;

class OrderShipped extends Notification implements ShouldQueue
{
    use Queueable;

    public function __construct(private string $orderNumber) {}

    public function via($notifiable): array
    {
        return ['connectmedia'];
    }

    public function toConnectMedia($notifiable): ConnectMediaMessage
    {
        return ConnectMediaMessage::create("Order {$this->orderNumber} has shipped.")
            ->from('MYSHOP'); // optional, defaults to CONNECTMEDIA_SENDER
    }
}

public function routeNotificationForConnectmedia($notification): ?string
{
    return $this->phone;
}

use Illuminate\Support\Facades\Notification;

Notification::route('connectmedia', '0712345678')->notify(new OrderShipped('A1023'));
bash
php artisan connectmedia:test 0712345678
php artisan connectmedia:balance
bash
php artisan vendor:publish --tag=connectmedia-config