|
|
@@ -5,7 +5,6 @@ namespace App\Http\Controllers;
|
|
5
|
5
|
use App\Http\Controllers\Controller;
|
|
6
|
6
|
use App\Http\Requests\TestTransaction\StoreTestTransactionRequest;
|
|
7
|
7
|
use App\Models\EntryTransaction;
|
|
8
|
|
-use App\Models\Member;
|
|
9
|
8
|
use App\Models\OutTransaction;
|
|
10
|
9
|
use App\Models\ParkingFee;
|
|
11
|
10
|
use App\Models\TypeVehicle;
|
|
|
@@ -51,6 +50,7 @@ class TestTransactionController extends Controller
|
|
51
|
50
|
->through(fn($transactionOut) => [
|
|
52
|
51
|
'id' => $transactionOut->id,
|
|
53
|
52
|
'createdAt' => $transactionOut->created_at,
|
|
|
53
|
+ 'platNumber' => $transactionOut->plat_number,
|
|
54
|
54
|
'entryTransactionId' => $transactionOut->entry_transaction_id,
|
|
55
|
55
|
]);
|
|
56
|
56
|
|
|
|
@@ -79,14 +79,27 @@ class TestTransactionController extends Controller
|
|
79
|
79
|
public function store(StoreTestTransactionRequest $request)
|
|
80
|
80
|
{
|
|
81
|
81
|
if ($request->id === 2) {
|
|
|
82
|
+ $vehicle = Vehicle::where('plat_number', $request->plat_number)->first();
|
|
|
83
|
+
|
|
82
|
84
|
// Check member or not
|
|
83
|
|
- $memberId = Vehicle::where('plat_number', $request->plat_number)->first('member_id');
|
|
|
85
|
+ if ($vehicle && $vehicle->member_id) {
|
|
|
86
|
+ $expDate = $vehicle->member->getRawOriginal('exp_date');
|
|
84
|
87
|
|
|
85
|
|
- if ($memberId) {
|
|
86
|
88
|
// Check expired member or not
|
|
87
|
|
- $expDate = $memberId->member->getRawOriginal('exp_date');
|
|
|
89
|
+ $exp = !Carbon::parse($expDate)->greaterThanOrEqualTo(now());
|
|
|
90
|
+
|
|
|
91
|
+ if ($exp) {
|
|
|
92
|
+ return back()->with('warning', __('words.member_expired'));
|
|
|
93
|
+ }
|
|
88
|
94
|
|
|
89
|
|
- $exp = Carbon::parse($expDate)->greaterThanOrEqualTo(now());
|
|
|
95
|
+ OutTransaction::create([
|
|
|
96
|
+ 'plat_number' => $request->plat_number,
|
|
|
97
|
+ 'entry_transaction_id' => $request->entry_transaction_id,
|
|
|
98
|
+ 'type_vehicle_id' => $vehicle->type_vehicle_id,
|
|
|
99
|
+ 'user_id' => auth()->user()->id,
|
|
|
100
|
+ ]);
|
|
|
101
|
+
|
|
|
102
|
+ return back()->with('success', __('messages.success.store.out_transaction'));
|
|
90
|
103
|
} else {
|
|
91
|
104
|
$entryTransactions = EntryTransaction::where('transaction_number', $request->entry_transaction_id)->first();
|
|
92
|
105
|
|
|
|
@@ -95,6 +108,8 @@ class TestTransactionController extends Controller
|
|
95
|
108
|
$longParkingPerHours = Carbon::parse($vehicleEntryTime)->floatDiffInRealHours(now());
|
|
96
|
109
|
|
|
97
|
110
|
$parkingFee = ParkingFee::get();
|
|
|
111
|
+
|
|
|
112
|
+ return back()->with('success', __('messages.success.store.out_transaction'));
|
|
98
|
113
|
}
|
|
99
|
114
|
} else {
|
|
100
|
115
|
EntryTransaction::create([
|