<?php

namespace App\Jobs;

use App\Procurement;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class ProcurementReceive implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
    protected $procurement;

    /**
     * Create a new job instance.
     *
     * @param Procurement $procurement
     */
    public function __construct(Procurement $procurement)
    {
        $this->procurement=$procurement;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $procurement=Procurement::query()->find($this->procurement->id);
        if ($procurement->status==2) $procurement->update(['status'=>3]);
    }
}
