refactoring on Articles, minor fixes

This commit is contained in:
ludo
2024-01-21 11:42:42 +01:00
parent 7e5b1fea89
commit 88a57a9c32
21 changed files with 467 additions and 367 deletions

View File

@@ -0,0 +1,25 @@
<?php
namespace App\Repositories\Shop;
use App\Models\Shop\Offer;
use App\Traits\Model\Basic;
class OfferStocks
{
public static function decreaseStock($item)
{
$offer = Offers::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 Offers::getField($id, 'stock_current');
}
}