This commit is contained in:
ludo
2024-06-17 21:56:42 +02:00
parent 561cd2248c
commit 38e477ee5f
5 changed files with 72 additions and 40 deletions

View File

@@ -55,15 +55,12 @@ class Customers
public static function editProfile($id = false)
{
$datatableOrders = new CustomerOrdersDataTable();
$datatableInvoices = new CustomerInvoicesDataTable();
return [
return $id ? [
'customer' => self::get($id, ['addresses', 'deliveries'])->toArray(),
'deliveries' => Deliveries::getAllWithSaleChannel()->toArray(),
'orders' => $datatableOrders->html(),
'invoices' => $datatableInvoices->html(),
];
'orders' => (new CustomerOrdersDataTable())->html(),
'invoices' => (new CustomerInvoicesDataTable())->html(),
] : abort('403');
}
public static function getAvatar($id = false)
@@ -151,6 +148,9 @@ class Customers
public static function edit($id)
{
if (!$id) {
abort('403');
}
$customer = self::get($id, ['delivery_addresses', 'invoice_addresses', 'sale_channels']);
$data = $customer->toArray();
$data['sale_channels'] = $customer->sale_channels->pluck('id')->toArray();