1. Go to this page and download the library: Download husnet/laravel-smsup.ch 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/ */
public function via($notifiable)
{
return ['smsUpCh'];
}
use Husnet\LaravelSmsUpCh\SmsUpChMessage;
...
public function toSmsUpCh($notifiable)
{
$message = new SmsUpChMessage();
$message->text($this->text);
return $message;
}
/**
* Route notifications for the SmsUp channel.
*
* @return string
*/
public function routeNotificationForSmsUpCh(): string
{
return $this->phone;
}
use Husnet\LaravelSmsUpCh\SmsUpChMessage;
use Husnet\LaravelSmsUpCh\Facades\SmsUpCh;
...
try {
$phone_owner->notify(new ClientNotification($message_text));
}
catch (\Exception $e) {
session()->flash('error', __('Error: SMS API Timeout'));
}
use Husnet\LaravelSmsUpCh\Events\SmsUpChMessageWasSent;
class SmsUpMessageSentListener
{
/**
* Handle the event.
*
* @param SmsUpChMessageWasSent $event
* @return void
*/
public function handle(SmsUpChMessageWasSent $event)
{
$response = $event->response; // Class SmsUpResponse
$message = $event->message; // Class SmsUpMessage
// flashing to session
session()->flash('message.to', $message->getTo());
session()->flash('message.text', $message->getText());
session()->flash('response.status', $response->getStatus());
session()->flash('response.message', $response->getMessage());
session()->flash('response.credits', $response->getCredits());
session()->flash('response.invalid', $response->getInvalid());
}
}