<?php

namespace App\Modules\Stock;

use Illuminate\Support\Facades\Event;

class CancelRequestedStock
{
    /**
     * Subscribe to events.
     *
     * @param  mixed $events
     *
     * @return null
     */
    public function subscribe($events)
    {
        $events->listen('CancelRequestedStock', 'App\Modules\Stock\CancelRequestedStock@fire');
    }

    /**
     * Fire the event.
     *
     * @param  \App\Modules\Stock\Stock $stock
     *
     * @return bool
     */
    public function fire($stock, $quantity)
    {
        $stock->decrement('quantity_to_order', $quantity);
    }
}
