You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The above works perfectly fine when run from CLI manually, but when executed from within another script, everything starts to fail and break. It works perfectly in Laravel 10, but not in Laravel 11. Below is the notification itself.
<?php
namespace App\Notifications\Hosts;
use App\Models\User;
use App\Models\Generator;
use App\Models\Hosts\Host;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use NotificationChannels\Twilio\TwilioChannel;
use NotificationChannels\Twilio\TwilioSmsMessage;
class HostOffline extends Notification implements ShouldQueue
{
use Queueable;
/**
* Create a new notification instance.
*/
public function __construct( public User $user, public $channels, public Host $host )
{
$this->channels = $channels ? $channels : ['database','mail'];
}
/**
* Get the notification's delivery channels.
*
* @return array<int, string>
*/
public function via($notifiable)
{
/*
This is because Twilios implementation of their service provider
is stupid and won't serialize properly otherwise.
*/
$methods = [];
foreach ($this->channels as $key) {
if ($key == 'sms') {
$methods[] = TwilioChannel::class;
} else {
$methods[] = $key;
}
}
return $methods;
}
/*
Write the Twilio notification
*/
public function toTwilio($notifiable)
{
if( $this->user->sms->verified_at )
{
return (new TwilioSmsMessage())
->content("A message goes here {$this->host->name}.");
}
}
}
The text was updated successfully, but these errors were encountered:
I'm able to successfully send via CLI and by calling the notification on Laravel v11.37.0 Do you have any other information?
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;
use NotificationChannels\Twilio\TwilioChannel;
use NotificationChannels\Twilio\TwilioSmsMessage;
class TestTwilioNotification extends Notification implements ShouldQueue
{
use Queueable;
/**
* Create a new notification instance.
*/
public function __construct()
{
//
}
public function via($notifiable): array
{
return [TwilioChannel::class];
}
public function toTwilio($notifiable): TwilioSmsMessage
{
return (new TwilioSmsMessage)
->content('This is a test SMS.');
}
}
Good day,
I receive the above error when using laravel-notification-channels/twilio on Queued items using ShouldQueue.
The above works perfectly fine when run from CLI manually, but when executed from within another script, everything starts to fail and break. It works perfectly in Laravel 10, but not in Laravel 11. Below is the notification itself.
The text was updated successfully, but these errors were encountered: