File tree Expand file tree Collapse file tree 6 files changed +2
-187
lines changed
Expand file tree Collapse file tree 6 files changed +2
-187
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -18,10 +18,9 @@ import TaxClassesIndex from './pages/tax-classes/Index.vue';
1818import TaxClassesEmpty from './pages/tax-classes/Empty.vue' ;
1919import TaxZonesIndex from './pages/tax-zones/Index.vue' ;
2020import TaxZonesEmpty from './pages/tax-zones/Empty.vue' ;
21+ import LowStockProducts from './components/widgets/LowStockProducts.vue' ;
2122import RecentOrders from './components/widgets/RecentOrders.vue' ;
22- import TopCustomers from './components/widgets/TopCustomers.vue' ;
2323import StatisticWidget from './components/widgets/StatisticWidget.vue' ;
24- import LowStockProducts from './components/widgets/LowStockProducts.vue' ;
2524
2625Statamic . 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} ) ;
Original file line number Diff line number Diff line change 66use DuncanMcClean \Cargo \Contracts \Orders \QueryBuilder ;
77use DuncanMcClean \Cargo \Query \Eloquent \QueriesCustomers ;
88use Illuminate \Support \Collection ;
9- use Illuminate \Support \LazyCollection ;
109use Illuminate \Support \Str ;
1110use 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 );
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 33namespace DuncanMcClean \Cargo \Stache \Query ;
44
55use DuncanMcClean \Cargo \Contracts \Orders \QueryBuilder ;
6- use DuncanMcClean \Cargo \Facades \Order ;
76use DuncanMcClean \Cargo \Orders \OrderStatus ;
87use DuncanMcClean \Cargo \Query \QueriesLineItems ;
9- use Illuminate \Support \Collection ;
10- use Illuminate \Support \LazyCollection ;
118use Statamic \Data \DataCollection ;
129use 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 ();
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments