<?php

namespace App\Jobs;

use App\Modules\UserTask\Services\UserTaskService;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

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

    private $uid;
    private $type;
    private $trigger_type;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct(int $uid, string $type, string $trigger_type)
    {
        $this->uid = $uid;
        $this->type = $type;
        $this->trigger_type = $trigger_type;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $service = new UserTaskService($this->uid);
        $service->trigger($this->type, $this->trigger_type);
    }
}
