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

@@ -14,6 +14,18 @@ class Customers
{
use Basic;
public static function getSaleChannel()
{
return SaleChannels::getDefault();
}
public static function getDeliveries()
{
$customer = self::getAuth();
return $customer ? $customer->deliveries : Deliveries::getDefault();
}
public static function getOptions()
{
return Customer::pluck('last_name', 'id');
@@ -23,13 +35,13 @@ class Customers
{
$id = $id ? $id : self::getId();
$datatableOrders = new CustomerOrdersDataTable();
$data = [
return [
'customer' => self::get($id, ['addresses', 'deliveries'])->toArray(),
'deliveries' => Deliveries::getAllWithSaleChannel()->toArray(),
'orders' => $datatableOrders->html(),
];
return $data;
}
public static function getAvatar($id = false)
@@ -48,7 +60,8 @@ class Customers
$filename = self::makeAvatarFilename($customer);
$name = $customer->first_name.' '.$customer->last_name;
$avatar = new Avatar();
$ret = $avatar->create($name)
return $avatar->create($name)
->setBackground('#F2B90F')
->setForeground('#335012')
->setBorder(1, '#28a745')
@@ -56,8 +69,6 @@ class Customers
->setDimension(36)
->setFontSize(16)
->save($filename);
return $ret;
}
public static function makeAvatarFilename($customer)
@@ -93,7 +104,7 @@ class Customers
{
$user = $id ? self::get($id) : self::getAuth();
return $user ? $user->first_name.' '.$user->last_name : '';
return $user ? $user->name : '';
}
public static function getAuth()
@@ -162,7 +173,7 @@ class Customers
public static function create($data)
{
$user = Customer::create([
return Customer::create([
'uuid' => Str::uuid(),
'active' => true,
'first_name' => $data['first_name'],
@@ -177,8 +188,6 @@ class Customers
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
return $user;
}
public static function getStorage($filename = false)