Merge pull request 'removed exit time as mandatory' (#583) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled

Reviewed-on: #583
This commit was merged in pull request #583.
This commit is contained in:
2026-05-11 10:06:25 +00:00

View File

@@ -41,12 +41,11 @@ class VehicleController extends Controller
if (!ctype_digit((string) $plantCode)) {
return response()->json([
'status' => 'error',
'status' => 'ERROR',
'status_description' => "plant code must be $plantCode a numeric value",
], 404);
}
$plantCod = Plant::where('code', $plantCode)->first();
if(!$plantCod){
@@ -56,6 +55,20 @@ class VehicleController extends Controller
], 404);
}
// $expectedKeys = ['vehicle_number','entry_time','exit_time','duration','type'];
// $requestKeys = array_keys($request->all());
// sort($expectedKeys);
// sort($requestKeys);
// if ($expectedKeys != $requestKeys) {
// return response()->json([
// 'status' => 'ERROR',
// 'status_description' => 'Send proper valid JSON structure'
// ], 400);
// }
$plantId = $plantCod->id;
$data = $request->all();
@@ -86,20 +99,20 @@ class VehicleController extends Controller
'status_description' => "Entry time cant't be empty!",
], 404);
}
else if(!$exitTimeRaw)
{
return response()->json([
'status' => 'ERROR',
'status_description' => "Exit time cant't be empty!",
], 404);
}
else if(!$duration)
{
return response()->json([
'status' => 'ERROR',
'status_description' => "Duration cant't be empty!",
], 404);
}
// else if(!$exitTimeRaw)
// {
// return response()->json([
// 'status' => 'ERROR',
// 'status_description' => "Exit time cant't be empty!",
// ], 404);
// }
// else if(!$duration)
// {
// return response()->json([
// 'status' => 'ERROR',
// 'status_description' => "Duration cant't be empty!",
// ], 404);
// }
else if(!$type)
{
return response()->json([
@@ -108,7 +121,6 @@ class VehicleController extends Controller
], 404);
}
if ($entryTimeRaw && !Carbon::hasFormat($entryTimeRaw, 'd/m/Y h:i:s A')) {
return response()->json([
'status' => 'ERROR',
@@ -123,7 +135,7 @@ class VehicleController extends Controller
}
else if ($duration && !preg_match('/^\d{2}:\d{2}:\d{2}$/', $duration)) {
return response()->json([
'status' => 'error',
'status' => 'ERROR',
'status_description' => "Invalid duration format $duration. Expected HH:MM:SS",
], 404);
}
@@ -136,7 +148,7 @@ class VehicleController extends Controller
? Carbon::createFromFormat('d/m/Y h:i:s A', $exitTimeRaw)
: null;
VehicleEntry::insert([
$record = VehicleEntry::insert([
'plant_id' => $plantId,
'vehicle_number' => $vehicleNo,
'entry_time' => $entryTime,
@@ -147,11 +159,19 @@ class VehicleController extends Controller
'updated_at' => now(),
]);
return response()->json([
'status' => 'success',
'status_description' => 'Vehicle entry inserted successfully'
], 200);
if($record){
return response()->json([
'status' => 'SUCCESS',
'status_description' => 'Vehicle entry inserted successfully'
], 200);
}
else
{
return response()->json([
'status' => 'ERROR',
'status_description' => 'Failed to insert record in the table vehicle entry'
], 404);
}
}
/**