This package provides a Laravel notification channel for sending SMS messages using the msegat.com SMS provider.
- Install the package:
composer require bitcodesa/msegat
- Publish the config file:
php artisan vendor:publish --tag="msegat-config"
- Configure the package:
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"),
];
- Configure Msegat service:
- Get your credentials:
- Create an account at msegat.com.
- Go to your dashboard.
- Obtain your API Key, Username, and Sender ID.
- Set environment variables:
- Open your
.env
file. - Add the following lines, replacing the placeholder values with your credentials:
- Open your
# Msegat credentials
MSEGAT_API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxx"
MSEGAT_USERNAME="BITCODE"
MSEGAT_SENDER="BITCODE"
- Add the Msegat channel to your notification class:
<?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"
- Send the sms notification:
$user = User::find(1);
$user->notify(new Reservation($reservation));
- Send otp notification:
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.
- The package supports unicode messages.
- The package allows you to customize the sender name displayed on the recipient's phone.
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.