refactoring on Articles, minor fixes
This commit is contained in:
@@ -18,6 +18,22 @@ class Offers
|
||||
];
|
||||
}
|
||||
|
||||
public static function decreaseStock($item)
|
||||
{
|
||||
$offer = self::get($item['offer_id']);
|
||||
$offer->stock_current = $offer->stock_current - $item['quantity'];
|
||||
if ($offer->stock_current <= 0) {
|
||||
$offer->stock_current = 0;
|
||||
}
|
||||
|
||||
return $offer->save();
|
||||
}
|
||||
|
||||
public static function getStockCurrent($id)
|
||||
{
|
||||
return self::getField($id, 'stock_current');
|
||||
}
|
||||
|
||||
public static function getWeight($id, $quantity = 1)
|
||||
{
|
||||
$offer = self::get($id);
|
||||
@@ -58,7 +74,7 @@ class Offers
|
||||
'tariff.price_lists.price_list_values',
|
||||
'variation',
|
||||
])->find($id);
|
||||
$images = Articles::getFullImagesByArticle($offer->article);
|
||||
$images = ArticleImages::getFullImagesByArticle($offer->article);
|
||||
$offer->article->image = Articles::getPreviewSrc($images[0] ?? false);
|
||||
|
||||
return $offer;
|
||||
@@ -111,7 +127,7 @@ class Offers
|
||||
|
||||
public static function getThumbSrc(Offer $offer)
|
||||
{
|
||||
$image = $offer->article ? Articles::getFullImageByArticle($offer->article) : false;
|
||||
$image = $offer->article ? ArticleImages::getFullImageByArticle($offer->article) : false;
|
||||
|
||||
return $image ? Articles::getThumbSrc($image) : false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user