1. Go to this page and download the library: Download abather/sms4jawaly 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/ */
namespace App\Notifications;
use Illuminate\Notifications\Notification;
use Sms4jawaly\Laravel\Message;
use Sms4jawaly\Laravel\Sms4JawalyChannel;
class WelcomeNotification extends Notification
{
public function via($notifiable)
{
return [Sms4JawalyChannel::class];
}
public function to4Jawaly($notifiable): Message
{
return Message::make("Welcome {$notifiable->name}!")
->phone($notifiable->phone) // Optional: override phone number
->sender('4jawaly'); // Optional: override sender name
}
}
Message::make('Your message text')
->phone('966500000000') // Set recipient phone number
->sender('4jawaly') // Set sender name
->message('New text'); // Update message text
public function to4Jawaly($notifiable): string
{
return "Your verification code is: {$this->code}";
}
use App\Notifications\WelcomeNotification;
$user = User::find(1);
$user->notify(new WelcomeNotification());
public function routeNotificationFor($channel)
{
if ($channel === 'sms-4-jawaly') {
return $this->mobile_number; // Use a different attribute
}
return $this->phone;
}
use App\Notifications\WelcomeNotification;
use Illuminate\Support\Facades\Notification;
Notification::route('sms-4-jawaly', '966500000000')
->notify(new WelcomeNotification());
[
'success' => bool, // Overall success status
'total_success' => int, // Number of successful sends
'total_failed' => int, // Number of failed sends
'job_ids' => array, // Array of job IDs from the API
'errors' => array // Errors by error message => numbers
]
[
'success' => bool, // Success status
'data' => mixed, // API response data
'error' => string // Error message (if failed)
]