public function scopeStock($query, $operator = null, $stock = null)
    {
        if ($operator && $stock) {
            return $query->whereHas('stocks', function ($query) use ($operator, $stock) {
                if ($output = $this->getOperator($operator)) {
                    return $query->where('quantity', $output[0], $stock);
                } else {
                    return $query;
                }
            });
        }

        return $query;
    }
public function scopeStock($query, $operator = null, $stock = null)
    {
        if ($operator && $stock) {
            return $query->whereHas('stocks', function ($query) use ($operator, $stock) {
                if ($output = $this->getOperator($operator)) {
                    return $query->where('quantity', $output[0], $stock);
                } else {
                    return $query;
                }
            });
        }

        return $query;
    }
public function scopeStock ( $ query , $ operator = null , $ stock = null ) { if ( $ operator && $ stock ) { return $ query -> whereHas ( 'stocks' , function ( $ query ) use ( $ operator , $ stock ) { if ( $ output = $ this -> getOperator ( $ operator ) ) { return $ query -> where ( 'quantity' , $ output [ 0 ] , $ stock ) ; } else { return $ query ; } } ) ; } return $ query ; }
Filters query by the inputted inventory item stock quantity.

@param $query
@param string $operator
@param string $stock

@return mixed
Filters query by the inputted inventory item stock quantity .