PHP code example of winalco / laravel-sms

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

    

winalco / laravel-sms example snippets


use Winalco\Sms\Models\SmsMessage;

// Single entry point: validates the Algerian number (05/06/07, +213, 00213),
// records the row, sends through the queue. Returns null (logged) if the number
// is invalid or on internal failure — never breaks the caller.
SmsMessage::queue(
    to: $user->phone,
    message: __('Winalco: payment confirmed. Ref :ref.', ['ref' => $ref]),
    notable: $order,                          // optional morph
    context: 'payment_confirmation',          // free-form, shown in your UIs
    idempotencyKey: 'order-paid-'.$order->id, // prevents double sends on the relay
);

// routes/console.php (or app/Console/Kernel.php)
Schedule::command('model:prune', ['--model' => [\Winalco\Sms\Models\SmsMessage::class]])->daily();