PHP code example of nextsms / laravel

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

    

nextsms / laravel example snippets




namespace App;

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

class User extends Authenticatable
{
    use Notifiable;

    /**
     * Route notifications for the NextSMS channel.
     *
     * @param  \Illuminate\Notifications\Notification  $notification
     * @return string
     */
    public function routeNotificationForNextSms($notification)
    {
        return $this->phone;
    }
}



use NotificationChannels\NextSms\NextSmsChannel;
use NotificationChannels\NextSms\NextSmsMessage;

class NewsWasPublished extends Notification
{

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return [NextSmsChannel::class];
    }

    public function toNextSms($notifiable)
    {
        return (new NextSmsMessage())
                    ->content('Your SMS message content');

    }
}

// import this 

use NotificationChannels\NextSms\NextSmsFacade as NextSms;

// in your controller
NextSms::singleDestination([
    'from' => 'NEXTSMS',
    'to' => '255716718040',
    'text' => 'Your message'
]);
bash
php artisan vendor:publish --provider="NotificationChannels\NextSms\NextSmsServiceProvider" --tag="config"