From 69993ff7753dd43791046e6a6106f0061bce9927 Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Fri, 24 Apr 2026 00:36:08 +0300 Subject: [PATCH] Fix: Profile visibility, Wallet login alias, and Notification Page crash --- app/Http/Controllers/AuthController.php | 10 ++++++++++ app/Http/Controllers/NotificationController.php | 2 +- app/Http/Controllers/PromoController.php | 2 +- app/Http/Controllers/RatingController.php | 6 +++++- app/Models/Driver.php | 2 +- app/Models/Passenger.php | 2 +- routes/api.php | 1 + 7 files changed, 20 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index d5dc7e1..970863a 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -420,6 +420,11 @@ class AuthController extends Controller */ public function passengerWalletLogin(Request $request): JsonResponse { + // Allow 'id' as an alias for 'phone' + if (!$request->has('phone') && $request->has('id')) { + $request->merge(['phone' => $request->input('id')]); + } + $request->validate([ 'phone' => 'required|string', 'password' => 'required|string', @@ -472,6 +477,11 @@ class AuthController extends Controller */ public function driverWalletLogin(Request $request): JsonResponse { + // Allow 'id' as an alias for 'phone' + if (!$request->has('phone') && $request->has('id')) { + $request->merge(['phone' => $request->input('id')]); + } + $request->validate([ 'phone' => 'required|string', 'password' => 'required|string', diff --git a/app/Http/Controllers/NotificationController.php b/app/Http/Controllers/NotificationController.php index 8affdde..21aa2c7 100644 --- a/app/Http/Controllers/NotificationController.php +++ b/app/Http/Controllers/NotificationController.php @@ -40,7 +40,7 @@ class NotificationController extends Controller ->get(); } - return response()->json(['status' => 'success', 'data' => $notifications]); + return response()->json(['status' => 'success', 'data' => $notifications, 'message' => $notifications]); } /** PUT /v2/notifications/{id}/read */ diff --git a/app/Http/Controllers/PromoController.php b/app/Http/Controllers/PromoController.php index 1d9d799..9426fad 100644 --- a/app/Http/Controllers/PromoController.php +++ b/app/Http/Controllers/PromoController.php @@ -32,7 +32,7 @@ class PromoController extends Controller }) ->get(); - return response()->json(['status' => 'success', 'data' => $promos]); + return response()->json(['status' => 'success', 'data' => $promos, 'message' => $promos]); } /** GET /v2/promos/check?code=XXX */ diff --git a/app/Http/Controllers/RatingController.php b/app/Http/Controllers/RatingController.php index 5e67b57..7b8a318 100644 --- a/app/Http/Controllers/RatingController.php +++ b/app/Http/Controllers/RatingController.php @@ -128,8 +128,12 @@ class RatingController extends Controller } /** GET /v2/ratings/passenger/{id} */ - public function passengerRating(string $id): JsonResponse + public function passengerRating(Request $request, string $id = null): JsonResponse { + $id = $id ?? $request->input('passenger_id'); + if (!$id) { + return response()->json(['status' => 'failure', 'message' => 'Passenger ID required'], 400); + } $ratings = DB::connection('primary')->table('ratingPassenger') ->where('passenger_id', $id) ->orderBy('created_at', 'desc') diff --git a/app/Models/Driver.php b/app/Models/Driver.php index e29594e..836fdb5 100644 --- a/app/Models/Driver.php +++ b/app/Models/Driver.php @@ -94,7 +94,7 @@ class Driver extends Model public function scopeActive($query) { - return $query->where('status', 'notDeleted'); + return $query->whereIn('status', ['notDeleted', 'active']); } public function scopeById($query, string $driverId) diff --git a/app/Models/Passenger.php b/app/Models/Passenger.php index 492f3f2..2c883b9 100644 --- a/app/Models/Passenger.php +++ b/app/Models/Passenger.php @@ -63,6 +63,6 @@ class Passenger extends Model public function scopeActive($query) { - return $query->where('status', 'notDeleted'); + return $query->whereIn('status', ['notDeleted', 'active']); } } diff --git a/routes/api.php b/routes/api.php index af4701e..d51b09d 100644 --- a/routes/api.php +++ b/routes/api.php @@ -124,6 +124,7 @@ Route::prefix('v2')->middleware(['hmac.auth', 'jwt.auth'])->group(function () { Route::get('/ratings/app', [RatingController::class, 'getAppFeedback']); Route::post('/ratings/app', [RatingController::class, 'storeAppFeedback']); Route::get('/ratings/driver/{id}', [RatingController::class, 'driverRating']); + Route::get('/ratings/passenger', [RatingController::class, 'passengerRating']); Route::get('/ratings/passenger/{id}', [RatingController::class, 'passengerRating']); // ── Promos ──