1. Go to this page and download the library: Download i-rocky/laravel-twilio 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/ */
/**
* @property string username
* @property string phone
* @property string phone_number
*/
clas User extends Authenticable {
use Notifiable;
...
public function routeNotificationForTwilio() {
return "+{$this->phone}";
}
public function laravelTwilioIdentity() {
return Str::snake($this->first_name);
}
}
use Rocky\LaravelTwilio\Foundation\TwilioMessage;
use Rocky\LaravelTwilio\Message\TwilioSMSMessage;
use Rocky\LaravelTwilio\Message\TwilioMMSMessage;
use Rocky\LaravelTwilio\Message\TwilioFaxMessage;
use Rocky\LaravelTwilio\Message\TwilioCallMessage;
use Rocky\LaravelTwilio\TwilioChannel;
class TwilioTestNotification extends Notification {
...
public function via($notifiable) {
return [TwilioChannel::class];
}
...
public function toTwilio($notifiable) {
// SMS
return (new TwilioSMSMessage())
->to('+receiver') // optional
->from('+sender') // optional
->text('Your message'); // ->mediaUrl('publicly accessible media url'); //