Skip to content

Commit 20a128d

Browse files
committed
rip out the top customers widget for now
i've saved my changes in a local branch in case i want to hack on it again.
1 parent 39d5ef1 commit 20a128d

File tree

6 files changed

+2
-187
lines changed

6 files changed

+2
-187
lines changed

resources/js/components/widgets/TopCustomers.vue

Lines changed: 0 additions & 62 deletions
This file was deleted.

resources/js/cp.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ import TaxClassesIndex from './pages/tax-classes/Index.vue';
1818
import TaxClassesEmpty from './pages/tax-classes/Empty.vue';
1919
import TaxZonesIndex from './pages/tax-zones/Index.vue';
2020
import TaxZonesEmpty from './pages/tax-zones/Empty.vue';
21+
import LowStockProducts from './components/widgets/LowStockProducts.vue';
2122
import RecentOrders from './components/widgets/RecentOrders.vue';
22-
import TopCustomers from './components/widgets/TopCustomers.vue';
2323
import StatisticWidget from './components/widgets/StatisticWidget.vue';
24-
import LowStockProducts from './components/widgets/LowStockProducts.vue';
2524

2625
Statamic.booting(() => {
2726
// Discounts
@@ -55,8 +54,7 @@ Statamic.booting(() => {
5554
Statamic.$inertia.register('cargo::TaxZones/Empty', TaxZonesEmpty);
5655

5756
// Widgets
57+
Statamic.$components.register('low-stock-products-widget', LowStockProducts);
5858
Statamic.$components.register('recent-orders-widget', RecentOrders);
59-
Statamic.$components.register('top-customers-widget', TopCustomers);
6059
Statamic.$components.register('statistic-widget', StatisticWidget);
61-
Statamic.$components.register('low-stock-products-widget', LowStockProducts);
6260
});

src/Orders/Eloquent/OrderQueryBuilder.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use DuncanMcClean\Cargo\Contracts\Orders\QueryBuilder;
77
use DuncanMcClean\Cargo\Query\Eloquent\QueriesCustomers;
88
use Illuminate\Support\Collection;
9-
use Illuminate\Support\LazyCollection;
109
use Illuminate\Support\Str;
1110
use Statamic\Query\EloquentQueryBuilder;
1211

@@ -44,12 +43,6 @@ public function whereHasLineItem(?Closure $callback = null): self
4443
return $this;
4544
}
4645

47-
public function getByCustomer(): LazyCollection
48-
{
49-
// TODO
50-
// customer-id => [order-a, order-b.... mapped to Order objects],
51-
}
52-
5346
public function pluck($column, $key = null)
5447
{
5548
$column = $this->column($column);

src/Query/QueriesCustomers.php

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/Stache/Query/OrderQueryBuilder.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@
33
namespace DuncanMcClean\Cargo\Stache\Query;
44

55
use DuncanMcClean\Cargo\Contracts\Orders\QueryBuilder;
6-
use DuncanMcClean\Cargo\Facades\Order;
76
use DuncanMcClean\Cargo\Orders\OrderStatus;
87
use DuncanMcClean\Cargo\Query\QueriesLineItems;
9-
use Illuminate\Support\Collection;
10-
use Illuminate\Support\LazyCollection;
118
use Statamic\Data\DataCollection;
129
use Statamic\Stache\Query\Builder;
1310

@@ -37,27 +34,6 @@ public function whereNotStatus(string|OrderStatus $status): self
3734
return $this;
3835
}
3936

40-
public function getByCustomer(): LazyCollection
41-
{
42-
$ordersByCustomer = [];
43-
44-
$ids = $this->pluck('id')->all();
45-
$index = $this->store->index('customer');
46-
47-
foreach ($index->getItems() as $key => $value) {
48-
if (! in_array($key, $ids)) {
49-
continue;
50-
}
51-
52-
isset($ordersByCustomer[$value])
53-
? $ordersByCustomer[$value][] = $key
54-
: $ordersByCustomer[$value] = [$key];
55-
}
56-
57-
return LazyCollection::make($ordersByCustomer)
58-
->map(fn ($items) => collect($items)->map(fn ($id) => $this->store->getItem($id)));
59-
}
60-
6137
public function sum(string $column)
6238
{
6339
return $this->pluck($column)->sum();

src/Widgets/TopCustomers.php

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)