better management of shipping and basket summary display

This commit is contained in:
ludo
2023-12-03 00:40:47 +01:00
parent 4bcfc7bc6d
commit ec509df665
26 changed files with 317 additions and 477 deletions

View File

@@ -3,9 +3,25 @@
namespace App\Repositories\Shop;
use App\Models\Shop\PriceList;
use App\Traits\Model\Basic;
class PriceLists
{
use Basic;
public static function init($tariffId = false)
{
return [
'sale_channels' => SaleChannels::getOptions(),
'statuses' => Tariffs::getStatuses(),
'taxes' => Taxes::getOptions(),
'price_list' => [
'tariff_id' => $tariffId,
'price_list_values' => array_fill(0, 3, ''),
],
];
}
public static function getByOfferAndSaleChannel($offer_id, $sale_channel_id)
{
return PriceList::bySaleChannel($sale_channel_id)->byOffer($offer_id)->get();
@@ -31,15 +47,6 @@ class PriceLists
return PriceList::byTariff($id)->get();
}
public static function getOptions()
{
return PriceList::pluck('name', 'id')->toArray();
}
public static function getAll()
{
return PriceList::orderBy('name', 'asc')->get();
}
public static function edit($id)
{
@@ -52,11 +59,6 @@ class PriceLists
return $price_list;
}
public static function get($id)
{
return PriceList::find($id);
}
public static function getPrices($id)
{
return PriceList::with('price_list_values')->find($id);
@@ -78,22 +80,8 @@ class PriceLists
return $price_list;
}
public static function create($data)
public static function getModel()
{
return PriceList::create($data);
}
public static function update($data, $id = false)
{
$id = $id ? $id : $data['id'];
$item = self::get($id);
$item->update($data);
return $item;
}
public static function destroy($id)
{
return PriceList::destroy($id);
return PriceList::query();
}
}