<?php

namespace App\Jobs\Bonus;

use App\Bonus\IdentityBonus;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Modules\User\Models\Order;
use Modules\User\Models\User;

class BuyIdentityJob implements ShouldQueue
{

    use Dispatchable, InteractsWithQueue;

    public $queue = 'BONUS';

    public $delay = 0;

    public $tries = 1;

    public $timeout = 30;

    protected $user;    //bonus

    protected $order; //bonus

    protected $source;//bonus

    public function __construct(User $user, Order $order, array $source = [])
    {
        $this->user   = $user->fresh();
        $this->order  = $order->fresh();
        $this->source = $source;
    }

    public function handle()
    {
        IdentityBonus::BuyIdentity($this->user, $this->order, $this->source);
    }

}