Selaa lähdekoodia

fix: customer details

Muhammad Iqbal Afandi 3 vuotta sitten
vanhempi
commit
091d078d99

+ 5
- 6
app/Http/Controllers/CustomerController.php Näytä tiedosto

@@ -7,7 +7,6 @@ use App\Http\Controllers\Controller;
7 7
 use App\Http\Requests\Customer\StoreCustomerRequest;
8 8
 use App\Http\Requests\Customer\UpdateCustomerRequest;
9 9
 use App\Models\Customer;
10
-use App\Models\Transaction;
11 10
 use App\Services\TransactionService;
12 11
 
13 12
 class CustomerController extends Controller
@@ -94,14 +93,14 @@ class CustomerController extends Controller
94 93
                 'name' => $customer->name,
95 94
                 'phone' => $customer->phone,
96 95
                 'gender_id' => (int) $customer->getRawOriginal('gender_id'),
97
-                'relation' => $customer->transaction()->exists(),
96
+                'relation' => $customer->transactions()->exists(),
98 97
             ],
99 98
             'genders' => [
100 99
                 ['label' => 'Perempuan', 'value' => 1],
101 100
                 ['label' => 'Laki-laki', 'value' => 2],
102 101
             ],
103 102
             'transactions' => [
104
-                'details' => $customer->transaction()
103
+                'details' => $customer->transactions()
105 104
                     ->latest()
106 105
                     ->paginate(10)
107 106
                     ->withQueryString()
@@ -119,9 +118,9 @@ class CustomerController extends Controller
119 118
                         'transactionStatusName' => $transaction->transactionStatus->name,
120 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 Näytä tiedosto

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