1. Go to this page and download the library: Download beziworld/laravel-serwersms 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/ */
beziworld / laravel-serwersms example snippets
use Beziworld\SerwerSms\Facades\SerwerSms;
use Beziworld\SerwerSms\Messages\SmsMessage;
// Shortcut
SerwerSms::sendText('500 600 700', 'Your code is 1234');
// Full builder
$result = SerwerSms::send(
SmsMessage::create('Your order #1001 has shipped')
->to(['500600700', '+48600700800'])
->from('Shop') // SMS FULL; ->eco() sends SMS ECO
->uniqueId('order1001a', 'order1001b') // one per recipient, returned in reports
->sendAt(now()->addHour())
);
$result->queued; // number of queued messages
$result->ids(); // SerwerSMS ids of the queued messages
$result->failedMessages(); // recipients rejected individually, with errorCode / errorMessage
use Beziworld\SerwerSms\Messages\{MmsMessage, PersonalizedMessage, VoiceMessage};
SerwerSms::sendPersonalized(
PersonalizedMessage::create()->add('500600700', 'Hi Jan')->add('600700800', 'Hi Ewa')
);
SerwerSms::sendVoice(VoiceMessage::create('Your visit is tomorrow at 10.')->to('500600700')->lector('Maja'));
$fileId = SerwerSms::uploadFile('mms', 'https://example.com/promo.jpg');
SerwerSms::sendMms(MmsMessage::create('Promo')->files($fileId)->text('-20% today')->to('500600700'));
SerwerSms::cancelScheduled(ids: ['111065e43c'], uniqueIds: ['order1001a']);
use Beziworld\SerwerSms\Messages\SmsMessage;
use Illuminate\Notifications\Notification;
class OrderShipped extends Notification
{
public function via(object $notifiable): array
{
return ['serwersms'];
}
public function toSerwerSms(object $notifiable): SmsMessage|string
{
return SmsMessage::create("Order {$this->order->number} has shipped");
}
}
public function routeNotificationForSerwersms(): ?string
{
return $this->phone;
}