浏览代码

fix: customer details

父节点
当前提交
091d078d99
共有 2 个文件被更改,包括 8 次插入9 次删除
  1. 5
    6
      app/Http/Controllers/CustomerController.php
  2. 3
    3
      resources/views/excel/customer-report.blade.php

+ 5
- 6
app/Http/Controllers/CustomerController.php 查看文件

7
 use App\Http\Requests\Customer\StoreCustomerRequest;
7
 use App\Http\Requests\Customer\StoreCustomerRequest;
8
 use App\Http\Requests\Customer\UpdateCustomerRequest;
8
 use App\Http\Requests\Customer\UpdateCustomerRequest;
9
 use App\Models\Customer;
9
 use App\Models\Customer;
10
-use App\Models\Transaction;
11
 use App\Services\TransactionService;
10
 use App\Services\TransactionService;
12
 
11
 
13
 class CustomerController extends Controller
12
 class CustomerController extends Controller
94
                 'name' => $customer->name,
93
                 'name' => $customer->name,
95
                 'phone' => $customer->phone,
94
                 'phone' => $customer->phone,
96
                 'gender_id' => (int) $customer->getRawOriginal('gender_id'),
95
                 'gender_id' => (int) $customer->getRawOriginal('gender_id'),
97
-                'relation' => $customer->transaction()->exists(),
96
+                'relation' => $customer->transactions()->exists(),
98
             ],
97
             ],
99
             'genders' => [
98
             'genders' => [
100
                 ['label' => 'Perempuan', 'value' => 1],
99
                 ['label' => 'Perempuan', 'value' => 1],
101
                 ['label' => 'Laki-laki', 'value' => 2],
100
                 ['label' => 'Laki-laki', 'value' => 2],
102
             ],
101
             ],
103
             'transactions' => [
102
             'transactions' => [
104
-                'details' => $customer->transaction()
103
+                'details' => $customer->transactions()
105
                     ->latest()
104
                     ->latest()
106
                     ->paginate(10)
105
                     ->paginate(10)
107
                     ->withQueryString()
106
                     ->withQueryString()
119
                         'transactionStatusName' => $transaction->transactionStatus->name,
118
                         'transactionStatusName' => $transaction->transactionStatus->name,
120
                         'transactionStatusId' => $transaction->transactionStatus->id,
119
                         'transactionStatusId' => $transaction->transactionStatus->id,
121
                     ]),
120
                     ]),
122
-                'totalTransaction' => $customer->transaction->count(),
123
-                'totalValue' => (new TransactionService)->totalPriceGroupAsString($customer->fresh()->transaction),
124
-                'totalDiscountGiven' => (new TransactionService)->totalDiscountGivenGroupAsString($customer->fresh()->transaction),
121
+                'totalTransaction' => $customer->transactions->count(),
122
+                'totalValue' => (new TransactionService)->totalPriceGroupAsString($customer->fresh()->transactions),
123
+                'totalDiscountGiven' => (new TransactionService)->totalDiscountGivenGroupAsString($customer->fresh()->transactions),
125
             ],
124
             ],
126
         ]);
125
         ]);
127
     }
126
     }

+ 3
- 3
resources/views/excel/customer-report.blade.php 查看文件

22
                     <td>{{ $customer->customer_number }}</td>
22
                     <td>{{ $customer->customer_number }}</td>
23
                     <td>{{ $customer->name }}</td>
23
                     <td>{{ $customer->name }}</td>
24
                     <td>{{ $customer->phone }}</td>
24
                     <td>{{ $customer->phone }}</td>
25
-                    <td>{{ $customer->transaction->count() }}</td>
25
+                    <td>{{ $customer->transactions->count() }}</td>
26
                     <td>
26
                     <td>
27
-                        {{ (new App\Services\TransactionService())->totalPriceGroupAsString($customer->fresh()->transaction) }}
27
+                        {{ (new App\Services\TransactionService())->totalPriceGroupAsString($customer->fresh()->transactions) }}
28
                     </td>
28
                     </td>
29
                     <td>
29
                     <td>
30
-                        {{ (new App\Services\TransactionService())->totalDiscountGivenGroupAsString($customer->fresh()->transaction) }}
30
+                        {{ (new App\Services\TransactionService())->totalDiscountGivenGroupAsString($customer->fresh()->transactions) }}
31
                     </td>
31
                     </td>
32
                 </tr>
32
                 </tr>
33
             @endforeach
33
             @endforeach