【问题标题】:How tags are used with Laravel Horizon标签如何与 Laravel Horizo​​n 一起使用
【发布时间】:2018-07-10 06:42:24
【问题描述】:

我在作业队列中的跟踪标签没有显示我期望的标签。改班后作业不处理。

我的工作示例类是:

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];
    }
}

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

我从网站上的示例转到 https://laravel.com/docs/5.5/horizon#tags

有人可以帮忙吗?谢谢

【问题讨论】:

  • 发送电子邮件时会发生什么?

标签: php laravel email tags laravel-horizon


【解决方案1】:

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

更改:

    return ['email', 'user:'.$this->user];

收件人:

    return ['email', 'user:'.$this->user->id];

【讨论】:

  • 这是正确的修复。非常感谢 Sapnesh,啤酒在我身上:)
  • @laquefe 哈哈,编码愉快!
猜你喜欢
  • 2021-11-07
  • 1970-01-01
  • 2011-06-27
  • 2019-07-01
  • 2020-05-16
  • 2022-12-30
  • 1970-01-01
  • 2022-10-20
  • 1970-01-01
相关资源
最近更新 更多