|
|
@@ -38,14 +38,14 @@ class TransactionController extends Controller
|
|
38
|
38
|
'id' => $transactionOut->id,
|
|
39
|
39
|
'entryCar' => $transactionOut->entryTransaction->created_at,
|
|
40
|
40
|
'outCar' => $transactionOut->created_at,
|
|
41
|
|
- 'totalTimeParking' => Carbon::parse(
|
|
42
|
|
- $transactionOut->getRawOriginal('created_at')
|
|
43
|
|
- )->diffForHumans(
|
|
44
|
|
- $transactionOut->entryTransaction->getRawOriginal('created_at')
|
|
|
41
|
+ 'totalTimeParking' => ParkingFeeService::totalTimeParkingHuman(
|
|
|
42
|
+ $transactionOut->entry_transaction_id
|
|
|
43
|
+ ),
|
|
|
44
|
+ 'totalPriceParking' => ParkingFeeService::totalPriceParkingString(
|
|
|
45
|
+ $transactionOut->entry_transaction_id
|
|
45
|
46
|
),
|
|
46
|
|
- 'totalPriceParking' => ParkingFeeService::totalPriceParkingString($transactionOut->entry_transaction_id),
|
|
47
|
47
|
'platNumber' => $transactionOut->plat_number,
|
|
48
|
|
- 'entryTransactionId' => $transactionOut->entry_transaction_id
|
|
|
48
|
+ 'entryTransactionId' => $transactionOut->entry_transaction_id,
|
|
49
|
49
|
]);
|
|
50
|
50
|
|
|
51
|
51
|
$typeVehicles = function () {
|
|
|
@@ -54,19 +54,33 @@ class TransactionController extends Controller
|
|
54
|
54
|
if ($vehicle) {
|
|
55
|
55
|
return [[
|
|
56
|
56
|
'value' => $vehicle->typeVehicle->id,
|
|
57
|
|
- 'label' => $vehicle->typeVehicle->type
|
|
|
57
|
+ 'label' => $vehicle->typeVehicle->type,
|
|
58
|
58
|
]];
|
|
59
|
59
|
} else {
|
|
60
|
60
|
return TypeVehicle::get()->transform(fn($typeVehicle) => [
|
|
61
|
61
|
'value' => $typeVehicle->id,
|
|
62
|
|
- 'label' => $typeVehicle->type
|
|
|
62
|
+ 'label' => $typeVehicle->type,
|
|
63
|
63
|
]);
|
|
64
|
64
|
}
|
|
65
|
65
|
};
|
|
66
|
66
|
|
|
|
67
|
+ $detailOutTransaction = function () {
|
|
|
68
|
+ if (request('transaction_number')) {
|
|
|
69
|
+ return [
|
|
|
70
|
+ 'totalTimeParking' => ParkingFeeService::totalTimeParkingHuman(
|
|
|
71
|
+ request('transaction_number')
|
|
|
72
|
+ ),
|
|
|
73
|
+ 'totalPriceParking' => ParkingFeeService::totalPriceParkingString(
|
|
|
74
|
+ request('transaction_number')
|
|
|
75
|
+ ),
|
|
|
76
|
+ ];
|
|
|
77
|
+ }
|
|
|
78
|
+ };
|
|
|
79
|
+
|
|
67
|
80
|
return inertia('transaction/Create.vue', compact([
|
|
68
|
81
|
'outTransactions',
|
|
69
|
|
- 'typeVehicles'
|
|
|
82
|
+ 'typeVehicles',
|
|
|
83
|
+ 'detailOutTransaction',
|
|
70
|
84
|
]));
|
|
71
|
85
|
}
|
|
72
|
86
|
|
|
|
@@ -93,7 +107,7 @@ class TransactionController extends Controller
|
|
93
|
107
|
'plat_number' => $request->plat_number,
|
|
94
|
108
|
'entry_transaction_id' => $request->entry_transaction_id,
|
|
95
|
109
|
'type_vehicle_id' => $vehicle->type_vehicle_id,
|
|
96
|
|
- 'user_id' => auth()->user()->id
|
|
|
110
|
+ 'user_id' => auth()->user()->id,
|
|
97
|
111
|
]);
|
|
98
|
112
|
|
|
99
|
113
|
return back()->with('success', __('messages.success.store.transaction'));
|
|
|
@@ -105,12 +119,12 @@ class TransactionController extends Controller
|
|
105
|
119
|
'plat_number' => $request->plat_number,
|
|
106
|
120
|
'entry_transaction_id' => $request->entry_transaction_id,
|
|
107
|
121
|
'type_vehicle_id' => $request->type_vehicle_id,
|
|
108
|
|
- 'user_id' => auth()->user()->id
|
|
|
122
|
+ 'user_id' => auth()->user()->id,
|
|
109
|
123
|
]);
|
|
110
|
124
|
|
|
111
|
125
|
$outTransaction->mutation()->create([
|
|
112
|
126
|
'type' => 1,
|
|
113
|
|
- 'amount' => ParkingFeeService::totalPriceParking($request->entry_transaction_id)
|
|
|
127
|
+ 'amount' => ParkingFeeService::totalPriceParking($request->entry_transaction_id),
|
|
114
|
128
|
]);
|
|
115
|
129
|
|
|
116
|
130
|
DB::commit();
|