|
|
@@ -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
|
}
|