I am trying to send SMS notifications using Nexmo in Laravel, I have been following the official documentation guide.
For some reason my notifications do not send, but I don't get any errors at all.
I've set up my Notification class:
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Message\NexmoMessage;
class bookingAdded extends Notification
{
use Queueable;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the Nexmo / SMS representation of the notification.
*
* @param mixed $notifiable
* @return NexmoMessage
*/
public function toNexmo($notifiable)
{
return (new NexmoMessage)
->content('Your SMS message content');
}
}
In my Booking
model I have added the routeNotificationForNexmo()
method to customize the phone number the notification is delivered to:
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
class Booking extends Model
{
use Notifiable;
/**
* Route notifications for the Nexmo channel.
*
* @return string
*/
public function routeNotificationForNexmo()
{
$intl_number = preg_replace('/^07/','447', $this->customer_phone);
return $intl_number;
}
}
In my BookingController
I am sending the actual SMS notification in my update
method:
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update(BookingRequest $request, $id)
{
$booking = Booking::find($id);
$booking->notify(new bookingAdded($booking))
}
When I update a record it saves without any errors at all, but I don't receive the sms. Anyone know what I'm doing wrong here?
Thanks
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2rWgzie
via IFTTT
Aucun commentaire:
Enregistrer un commentaire