PHP code example of ayles-software / laravel-sms-messagemedia

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


'message_media' => [
    'key' => env('MESSAGE_MEDIA_KEY'),
    'secret'  => env('MESSAGE_MEDIA_SECRET'),
    'from' => env('MESSAGE_MEDIA_FROM'),
],

namespace App\Notifications;

use Illuminate\Notifications\Notification;
use AylesSoftware\MessageMedia\MessageMediaChannel;
use AylesSoftware\MessageMedia\MessageMediaMessage;

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

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

    public function toMessageMedia($notifiable)
    {
        return (new MessageMediaMessage)
            ->message("SMS test to user #{$notifiable->id} with token {$this->token} by MessageMedia")
            ->from('Dory');
            
        // setting a delay when the sms should be sent
        return (new MessageMediaMessage)
            ->message("SMS test to user #{$notifiable->id} with token {$this->token} by MessageMedia")
            ->from('Dory')
            ->delay(now()->addHours(6));
    }
}

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

$user = User::find(1);

$user->notify(new SmsTest);