app/Models/Inventory.php
public function scopeSku($query, $sku = null)
    {
        if ($sku) {
            return $query->whereHas('sku', function ($query) use ($sku) {
                return $query->where('code', 'LIKE', '%'.$sku.'%');
            });
        }

        return $query;
    }
public function scopeSku($query, $sku = null)
    {
        if ($sku) {
            return $query->whereHas('sku', function ($query) use ($sku) {
                return $query->where('code', 'LIKE', '%'.$sku.'%');
            });
        }

        return $query;
    }
Filters query by the inputted inventory sku.

@param $query
@param string $sku

@return mixed