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;
}