PHP code example of smsaero / smsaero_laravel

1. Go to this page and download the library: Download smsaero/smsaero_laravel 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/ */

    

smsaero / smsaero_laravel example snippets


use SmsAero\Laravel\Facades\SmsAero;

SmsAero::message()->send([
    'number' => '70000000000',
    'text'   => 'Hello, World!',
]);

$balance = SmsAero::user()->getBalance();

use SmsAero\Laravel\Facades\SmsAero;

$result = SmsAero::sendSms('70000000000', 'Hello, World!');
// $result->id, $result->status, $result->cost, $result->recipient, $result->raw

$balance = SmsAero::guard()->user()->getBalance();
SmsAero::guard()->message()->send(['number' => '70000000000', 'text' => 'Hi', 'sign' => 'SMS Aero']);

use SmsAero\SmsAeroMessage;

public function __construct(private SmsAeroMessage $sms) {}

$this->sms->send(['number' => '70000000000', 'text' => 'Hello, World!']);

use Illuminate\Notifications\Notification;
use SmsAero\Laravel\Notifications\SmsAeroMessage;

class OrderShipped extends Notification
{
    public function via(object $notifiable): array
    {
        return ['smsaero'];
    }

    public function toSmsAero(object $notifiable): SmsAeroMessage
    {
        return SmsAeroMessage::create("Order #{$this->id} shipped")->sign('MyShop');
    }
}

public function routeNotificationForSmsAero(): string
{
    return $this->phone;
}

class OrderShipped extends Notification implements ShouldQueue
{
    use Queueable;
}

use SmsAero\Laravel\Facades\SmsAero;

$fake = SmsAero::fake();

// ... code under test sends SMS ...

$fake->assertSent();
$fake->assertSentTo('70000000000');
$fake->assertSentCount(1);
$fake->assertNothingSent();
bash
php artisan vendor:publish --tag=smsaero-config