Applied manual JWT check and restored all driver fields68j2

This commit is contained in:
Hamza-Ayed
2026-04-25 15:07:51 +03:00
parent da590e7fc0
commit 61212b60af
5 changed files with 52 additions and 7 deletions

View File

@@ -176,4 +176,37 @@ class ProfileController extends Controller
return response()->json(['status' => 'success', 'message' => 'Sham Cash details updated']);
}
/**
* POST /v2/profile/driver/car
*/
public function updateDriverCar(Request $request): JsonResponse
{
$id = $request->attributes->get('_jwt_user_id');
$car = CarRegistration::where('driverID', $id)->where('isDefault', 1)->first();
if (!$car) {
return response()->json(['status' => 'failure', 'message' => 'Car not found'], 404);
}
$fields = ['make', 'model', 'year', 'color', 'color_hex', 'expiration_date', 'vin', 'car_plate'];
$updates = [];
foreach ($fields as $f) {
if ($request->has($f)) {
$val = $request->input($f);
if (in_array($f, CarRegistration::ENCRYPTED_FIELDS)) {
$updates[$f] = $this->enc->encrypt($val);
} else {
$updates[$f] = $val;
}
}
}
if (!empty($updates)) {
$car->update($updates);
}
return response()->json(['status' => 'success', 'message' => 'Vehicle details updated']);
}
}