fix: make the selected channel apply changes to product each time

This commit is contained in:
Valentin Lab
2025-10-05 12:33:08 +02:00
parent cc8dfa29b4
commit a5b2196b32
6 changed files with 131 additions and 30 deletions

View File

@@ -179,6 +179,24 @@ class Customers
return $customer->sale_channels()->sync($saleChannels);
}
public static function setDefaultSaleChannel($customerId, $saleChannelId)
{
if (! $customerId) {
return false;
}
$customer = self::get($customerId);
if (! $customer) {
return false;
}
$customer->default_sale_channel_id = $saleChannelId ?: null;
$customer->save();
return $customer->fresh(['sale_channels']);
}
public static function create($data)
{
$data['uuid'] = Str::uuid();