回答編集履歴
5
Fix
answer
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
Sales::whereBetween('date', [
|
3
3
|
$startDate, $endDate
|
4
4
|
])->withCount(['products' => function ($query) {
|
5
|
-
|
5
|
+
$query->groupBy('sales_product.product_id');
|
6
6
|
}])->get();
|
7
7
|
|
8
8
|
|
4
Fix
answer
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
```PHP
|
2
|
-
|
3
|
-
$startDate = Carbon::createFromFormat('Y-m-d', now())->startOfDay();
|
4
|
-
$endDate = Carbon::createFromFormat('Y-m-d', now())->endOfDay();
|
5
|
-
|
6
|
-
|
7
2
|
Sales::whereBetween('date', [
|
8
3
|
$startDate, $endDate
|
4
|
+
])->withCount(['products' => function ($query) {
|
9
|
-
|
5
|
+
$query->groupBy('sales_product.product_id');
|
6
|
+
}])->get();
|
10
7
|
|
8
|
+
|
11
9
|
```
|
3
Fix
answer
CHANGED
@@ -1,4 +1,11 @@
|
|
1
1
|
```PHP
|
2
|
-
Sales::whereBetween('date', '2020-xx-xx xx:xx:xx', '2021-xx-xx xx:xx:xx')->products()->groupBy('sales_product.product_id')->get();
|
3
2
|
|
3
|
+
$startDate = Carbon::createFromFormat('Y-m-d', now())->startOfDay();
|
4
|
+
$endDate = Carbon::createFromFormat('Y-m-d', now())->endOfDay();
|
5
|
+
|
6
|
+
|
7
|
+
Sales::whereBetween('date', [
|
8
|
+
$startDate, $endDate
|
9
|
+
])->products()->groupBy('sales_product.product_id')->get();
|
10
|
+
|
4
11
|
```
|
2
Fix
answer
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
```PHP
|
2
|
+
Sales::whereBetween('date', '2020-xx-xx xx:xx:xx', '2021-xx-xx xx:xx:xx')->products()->groupBy('sales_product.product_id')->get();
|
2
3
|
|
3
|
-
Sales::find(id)->products()->whereDate('sales_product.created_at', now())->groupBy('sales_product.product_id')->get();
|
4
|
-
|
5
4
|
```
|
1
Fix
answer
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
```PHP
|
2
2
|
|
3
|
-
Sales::find(id)->products()->whereDate('sales_product.created_at', now())->
|
3
|
+
Sales::find(id)->products()->whereDate('sales_product.created_at', now())->groupBy('sales_product.product_id')->get();
|
4
4
|
|
5
5
|
```
|