PHP code example of ayles-software / laravel-sms-mobile-message

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

    

ayles-software / laravel-sms-mobile-message example snippets


'mobile_message' => [
    'key' => env('MOBILE_MESSAGE_KEY'),
    'secret'  => env('MOBILE_MESSAGE_SECRET'),
    'from' => env('MOBILE_MESSAGE_FROM'),
],

namespace App\Notifications;

use Illuminate\Notifications\Notification;
use AylesSoftware\MobileMessage\MobileMessageChannel;
use AylesSoftware\MobileMessage\MobileMessageMessage;

class SmsTest extends Notification
{
    public function __construct(public string $token)
    {
    }

    public function via($notifiable)
    {
        return [MobileMessageChannel::class];
    }

    public function toMobileMessage($notifiable)
    {
        return (new MobileMessageMessage)
            ->message("SMS test to user #{$notifiable->id} with token {$this->token} by MobileMessage")
            ->from('Dory');
    }
}

public function routeNotificationForMobileMessage()
{
    return $this->phone;
}

$user = User::find(1);

$user->notify(new SmsTest);