adjust deliveries by customer

This commit is contained in:
ludo
2023-12-11 21:07:49 +01:00
parent 25b78f3380
commit df65516b36
8 changed files with 108 additions and 80 deletions

View File

@@ -19,15 +19,15 @@ class Deliveries
public static function getByCustomer($customerId = false)
{
$customer = Customers::get($customerId);
$saleChannels = $customer->sale_channels->pluck('id')->toArray();
$customer = $customerId ? Customers::get($customerId) : Customers::getAuth();
$saleChannels = $customer ? $customer->sale_channels->pluck('id')->toArray() : false;
return self::getBySaleChannels($saleChannels);
return $saleChannels ? self::getBySaleChannels($saleChannels) : false;
}
public static function getBySaleChannels($saleChannels)
{
return Delivery::bySaleChannels($saleChannels)->get();
return Delivery::bySaleChannels($saleChannels)->with('sale_channel')->get();
}
public static function getSaleChannelId($deliveryId)