change homepages to contents, add new methods to deliveries and sale_channels by customer

This commit is contained in:
ludo
2023-12-09 23:55:50 +01:00
parent 7561a8e8ba
commit 71ecb13af0
28 changed files with 185 additions and 153 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Repositories\Shop;
use App\Models\Shop\Delivery;
use App\Repositories\Shop\Customers;
use App\Traits\Model\Basic;
class Deliveries
@@ -16,6 +17,19 @@ class Deliveries
];
}
public static function getByCustomer($customerId = false)
{
$customer = Customers::get($customerId);
$saleChannels = $customer->sale_channels->pluck('id')->toArray();
return self::getBySaleChannels($saleChannels);
}
public static function getBySaleChannels($saleChannels)
{
return Delivery::bySaleChannels($saleChannels)->get();
}
public static function getSaleChannelId($deliveryId)
{
return $deliveryId ? Deliveries::getField($deliveryId, 'sale_channel_id') : SaleChannels::getDefaultID();
@@ -26,18 +40,6 @@ class Deliveries
return Delivery::active()->atHouse()->first();
}
public static function getOptions()
{
return Delivery::orderBy('name', 'asc')->pluck('name', 'id')->toArray();
}
public static function getAll($relations = false)
{
$model = $relations ? Delivery::with($relations) : Delivery::query();
return $model->orderBy('name', 'asc')->get();
}
public static function getAllWithSaleChannel()
{
return Delivery::orderBy('name', 'asc')->active()->public()->with('sale_channel')->get();