Applied manual JWT check and restored all driver fields68j2
This commit is contained in:
@@ -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']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user