PHP code example of davidpella / beem-sms-laravel

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

    

davidpella / beem-sms-laravel example snippets


use App\Notifications\AccountCreated;
 
$user->notify(new AccountCreated);

use App\Notifications\AccountCreated;
use Illuminate\Support\Facades\Notification;

Notification::route("beem-sms", "255762000000")->notify(new AccountCreated);

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use DavidPella\BeemSms\Channel\BeemSmsChannel;
use Illuminate\Notifications\Notification;
use DavidPella\BeemSms\Channel\BeemSmsMessage;

class AccountCreated extends Notification
{
    use Queueable;

    public function via($notifiable):array
    {
        return [BeemSmsChannel::class]; // or ["beem-sms"]
    }

    public function toBeemSms($notifiable):BeemSmsMessage
    {
        return (new BeemSmsMessage())
            ->content("Your {$notifiable->name} account was created!");
    }
}

namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable
{
    use Notifiable;
    
    public function routeNotificationForBeemSms()
    {
        return $this->phone_number;
    }
}


namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable
{
    use Notifiable;
    
    public function routeNotificationForBeemSms()
    {
        return "255762000000";
    }
}


use DavidPella\BeemSms\Facades\BeemSms;

BeemSms::send([
    "recipient" => "255762000000",
    "message" => "Using the facade to send a message.",
]);

app("DavidPella\BeemSms\BeemSmsClient")
    ->recipient("255762000000")
    ->message("Send sms message using laravel service container")
    ->dispatch();
shell
php artisan vendor:publish --provider="DavidPella\BeemSms\BeemSmsServiceProvider"