Laravel Horizo​​n如何使用标签

2 php tags email laravel laravel-horizon

我在作业队列中的跟踪标签未显示我期望的标签。更改为类后,作业不会处理。

我的工作示例班是:

class EmailUser implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * The user instance.
     *
     * @var \App\User
     */
    public $user;

    /**
     * Create a new job instance.
     *
     * @param  \App\User  $user
     * @return void
     */
    public function __construct(User  $user)
    {
        $this->user = $user;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        Mail::to('fesher@example.com')->send(new ApplicationReceivedEmail());
    }

   /**
     * Get the tags that should be assigned to the job.
     *
     * @return array
     */
    public function tags()
    {
        return ['email', 'user:'.$this->user];
    }
}
Run Code Online (Sandbox Code Playgroud)

现在,在我手动标记作业类别之前,电子邮件将正常发送并且可以正常工作。添加标签方法会杀死进程,不再正常发送电子邮件。

我从网站上的示例中查找https://laravel.com/docs/5.5/horizo​​n#tags

有人可以帮忙吗?谢谢

Sap*_*aik 5

您正在尝试将Eloquent集合连接到标记字符串,该字符串应类似于a nameID

更改:

    return ['email', 'user:'.$this->user];
Run Code Online (Sandbox Code Playgroud)

至:

    return ['email', 'user:'.$this->user->id];
Run Code Online (Sandbox Code Playgroud)