bitcodesa/msegat is a Laravel package for notification channel for msegate msegat.com.
It currently has 1 GitHub stars and 981 downloads on Packagist (latest version 2.5.0).
Install it with composer require bitcodesa/msegat.
Discover more Laravel packages by bitcodesa
or browse all Laravel packages to compare alternatives.
Last updated
This package provides a Laravel notification channel for sending SMS messages using the msegat.com SMS provider.
composer require bitcodesa/msegat
php artisan vendor:publish --tag="msegat-config"
Edit the published config file (config/msegat.php) with your Msegat credentials:
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"),
];
.env file.# Msegat credentials
MSEGAT_API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxx"
MSEGAT_USERNAME="BITCODE"
MSEGAT_SENDER="BITCODE"
Message model, you have to publish the table:php artisan vendor:publish --tag="msegat-migrations"
make sure that you allow the creation through:
MSEGAT_MESSAGES_LOG=true
you can use Messageable trait to get any register that linked to any notifiable model:
class User extends Authenticatable
{
use \BitcodeSa\Msegat\Messageable;
}
then you can get messages through:
$user->messages
<?php
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
}
Available Method for MsegatMessage object:
timeToExec("YYYY-MM-DD HH:i:SS") allow you to specify the time that the message should be sent.unicode("UTF8") specify unicode for the message by default it is "UTF8".type("TYPE_SMS") specify message type you can choose between SMS or OTP.sender($sender) specify sender name.lang("ar") specify OTP language by defualt it is "ar"$user = User::find(1);
$user->notify(new Reservation($reservation));
NOTE:This feature not working from the source msegat.com
$user = User::find(1);
$user->notify(new SendOtp($reservation));
SendOtp Class:
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");
}
}
NOTE:This feature not working from the source msegat.com
$user = \App\Models\User::first();
$otp = new \BitcodeSa\Msegat\MsegatVerifyOtp();
$otp->validate($user, $code);
NOTE:This feature not working from the source msegat.com
By default, the Msegat notification channel uses the phone property on the notifiable model to identify the recipient.
If your model uses a different attribute for phone numbers, you can override the default behavior by implementing
the routeNotificationForMsegat() method on your notifiable model:
class User extends Authenticatable
{
use Notifiable;
public function routeNotificationForMsegat()
{
return $this->mobile;
}
}
This instructs the package to use the mobile attribute instead of phone to find the recipient's phone number.
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.