【发布时间】:2020-06-09 17:53:38
【问题描述】:
这个在我的本地服务器上运行良好,因为我可以运行命令。
php artisan queue:work
但是如何在实时服务器上实现呢? 我真的被这个问题困住了。但是因为我想通过邮件发送通知。所以,我正在关注使用 laravel 默认队列功能,因为它不会延迟并自动完成它的工作。所以,如果你能帮忙的话,真的很感激。
提前谢谢..
//我的.env配置
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=database
SESSION_DRIVER=file
SESSION_LIFETIME=120
//我的新奖学金课程
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class NewScholarship extends Notification implements ShouldQueue
{
use Queueable;
public $scholarship;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($scholarship)
{
$this->scholarship = $scholarship;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->greeting('Hello, Subscriber!')
->subject('New Scholarship has been published')
->line('New Scholarship info has been published to our website')
->line('Titled as: '.$this->scholarship->title)
->line('To have a look click the button below')
->action('View details', url('s/details',$this->scholarship->slug))
->line('Thank you for your subscription!');
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}
【问题讨论】: