Wednesday, January 31, 2018

How tags are used with Laravel Horizon - development

How tags are used with Laravel Horizon

My tracking tags in job queue does not show the tags I expect. Job does not process after change to class.

My job example class is :

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

    /**
     * The user instance.
     *
     * @var AppUser
     */
    public $user;

    /**
     * Create a new job instance.
     *
     * @param  AppUser  $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];
    }
}

Now before I manually tag job class emails are sent normally and all works. Adding tags method kills process, emails are no longer sent normally.

I go from example on website here https://laravel.com/docs/5.5/horizon#tags

Someone can help? Thanks



from Laravel Questions and Answers https://laravelquestions.com/php/how-tags-are-used-with-laravel-horizon/
via Lzo Media

No comments:

Post a Comment