PHP code example of bitcodesa / msegat

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

    

bitcodesa / msegat example snippets


return [
    "api_url" => env("MSEGAT_API_URL", "https://www.msegat.com/gw/sendsms.php"),
    "api_key" => env("MSEGAT_API_KEY", ""),
    "username" => env("MSEGAT_USERNAME", ""),
    "sender" => env("MSEGAT_SENDER", ""),
    "unicode" => env("MSEGAT_UNICODE", "UTF8"),
];

# Msegat credentials
MSEGAT_API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxx"
MSEGAT_USERNAME="BITCODE"
MSEGAT_SENDER="BITCODE"

MSEGAT_MESSAGES_LOG=true

class User extends Authenticatable 
{
    use \BitcodeSa\Msegat\Messageable;
}

$user->messages



namespace App\Notifications\ReservationNotifications;

use App\Models\Reservation;
use BitcodeSa\Msegat\MsegatMessage;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use BitcodeSa\Msegat\MsegatChannel;

class Reservation extends Notification
{
    use Queueable;
    protected Reservation $reservation;
    
    public function __construct(Reservation $reservation)
    {
        $this->reservation = $reservation;
    }
    public function via(object $notifiable): array
    {
        return [
                    MsegatChannel::class,
                    // Other notification channels
                ];
    }

    public function toMsegat()
    {
        return new MsegatMessage($this->reservation->title);
    }
    // Other notification methods
}

$user = User::find(1);
$user->notify(new Reservation($reservation));

$user = User::find(1);
$user->notify(new SendOtp($reservation));

class SendOtp extends Notification
{
    use Queueable;

    public function __construct()
    {
        //
    }

    public function via(object $notifiable): array
    {
        return [MsegatChannel::class];
    }

    public function toMsegat()
    {
        return (new MsegatMessage())
            ->type(MsegatMessage::TYPE_OTP)
            ->lang("en");
    }
}

$user = \App\Models\User::first();
$otp = new \BitcodeSa\Msegat\MsegatVerifyOtp();
$otp->validate($user, $code);

class User extends Authenticatable 
{
    use Notifiable;
    
    public function routeNotificationForMsegat()
    {
        return $this->mobile;
    }
}
bash
php artisan vendor:publish --tag="msegat-config"
bash
php artisan vendor:publish --tag="msegat-migrations"