Stevebauman\Inventory\Traits\InventoryTrait::findBySku PHP Метод

findBySku() публичный статический Метод

Returns an item record by the specified SKU code.
public static findBySku ( string $sku ) : boolean
$sku string
Результат boolean
    public static function findBySku($sku)
    {
        /*
         * Create a new static instance
         */
        $instance = new static();
        /*
         * Try and find the SKU record
         */
        $sku = $instance->sku()->getRelated()->with('item')->where('code', $sku)->first();
        /*
         * Check if the SKU was found, and if an item is
         * attached to the SKU we'll return it
         */
        if ($sku && $sku->item) {
            return $sku->item;
        }
        /*
         * Return false on failure
         */
        return false;
    }