PHP code example of clevyr / laravel-twilio-channel
1. Go to this page and download the library: Download clevyr/laravel-twilio-channel 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/ */
namespace App\Notifications;
use Clevyr\LaravelTwilioChannel\Channels\TwilioChannel;
use Clevyr\LaravelTwilioChannel\Contracts\TwilioNotification;
use Clevyr\LaravelTwilioChannel\Messages\TwilioMessage;
use Illuminate\Notifications\Notification;
class MyNotification extends Notification implements TwilioNotification {
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return [TwilioChannel::class];
}
/**
* Get the twilio representation of the notification.
*
* @param mixed $notifiable
* @return \Clevyr\LaravelTwilioChannel\Messages\TwilioMessage
*/
public function toTwilio($notifiable)
{
return (new TwilioMessage)
->line('Your first line.')
->line('A second line, with a break between the last line.');
}
class User extends Authenticatable
{
public $twilioPhoneNumberField = 'primary_phone_number';
//
}
Now if you generate a notification from a `User` object, `TwilioChannel`
will use the user's `primary_phone_number` field to send messages.