diff --git a/app/Http/Controllers/Api/ReportController.php b/app/Http/Controllers/Api/ReportController.php index 79b4e96..e9b2b16 100644 --- a/app/Http/Controllers/Api/ReportController.php +++ b/app/Http/Controllers/Api/ReportController.php @@ -26,7 +26,9 @@ public function reportFromWorker(Request $request) $validator = Validator::make($request->all(), [ 'type' => 'required|in:Chat,Review', 'item_id' => 'required', + 'user_id' => 'nullable', 'reason' => 'required|string|max:255', + 'others' => 'nullable|string|max:255', 'description' => 'nullable|string|max:2000', ]); @@ -90,17 +92,23 @@ public function reportFromWorker(Request $request) $reportId = 'REP-' . Str::upper(Str::random(8)); + $actualReason = $request->reason; + if (strtolower($request->reason) === 'others' && $request->filled('others')) { + $actualReason = 'Others: ' . $request->others; + } + // Insert to moderation_reports DB::table('moderation_reports')->insert([ 'id' => $reportId, 'type' => $request->type, + 'reported_user_id' => $request->user_id, 'reported_user_name' => $reportedName, 'reported_user_role' => $reportedRole, 'reported_user_avatar' => $reportedAvatar, 'reported_by_name' => $worker->name, 'reported_by_role' => 'Worker', 'reported_by_avatar' => null, - 'reason' => $request->reason, + 'reason' => $actualReason, 'priority' => 'Medium', 'status' => 'Pending', 'description' => $request->description, @@ -148,7 +156,9 @@ public function reportFromEmployer(Request $request) $validator = Validator::make($request->all(), [ 'type' => 'required|in:Chat,Review', 'item_id' => 'required', + 'user_id' => 'nullable', 'reason' => 'required|string|max:255', + 'others' => 'nullable|string|max:255', 'description' => 'nullable|string|max:2000', ]); @@ -212,17 +222,23 @@ public function reportFromEmployer(Request $request) $reportId = 'REP-' . Str::upper(Str::random(8)); + $actualReason = $request->reason; + if (strtolower($request->reason) === 'others' && $request->filled('others')) { + $actualReason = 'Others: ' . $request->others; + } + // Insert to moderation_reports DB::table('moderation_reports')->insert([ 'id' => $reportId, 'type' => $request->type, + 'reported_user_id' => $request->user_id, 'reported_user_name' => $reportedName, 'reported_user_role' => $reportedRole, 'reported_user_avatar' => $reportedAvatar, 'reported_by_name' => $employer->name, 'reported_by_role' => 'Sponsor', 'reported_by_avatar' => null, - 'reason' => $request->reason, + 'reason' => $actualReason, 'priority' => 'Medium', 'status' => 'Pending', 'description' => $request->description, diff --git a/database/migrations/2026_06_08_122218_add_reported_user_id_to_moderation_reports_table.php b/database/migrations/2026_06_08_122218_add_reported_user_id_to_moderation_reports_table.php new file mode 100644 index 0000000..0367aac --- /dev/null +++ b/database/migrations/2026_06_08_122218_add_reported_user_id_to_moderation_reports_table.php @@ -0,0 +1,28 @@ +string('reported_user_id')->nullable()->after('type'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('moderation_reports', function (Blueprint $table) { + $table->dropColumn('reported_user_id'); + }); + } +}; diff --git a/public/swagger.json b/public/swagger.json index 2858454..23f0f4c 100644 --- a/public/swagger.json +++ b/public/swagger.json @@ -1364,11 +1364,21 @@ "example": "1", "description": "The ID of the conversation or review being reported." }, + "user_id": { + "type": "string", + "example": "5", + "description": "Optional ID of the user being reported." + }, "reason": { "type": "string", - "example": "Inappropriate messages", + "example": "Others", "description": "The reason for submitting this report." }, + "others": { + "type": "string", + "example": "Spam and malicious links", + "description": "Custom reason string. Used only if reason is 'Others'." + }, "description": { "type": "string", "example": "The other party sent highly inappropriate and insulting messages.", @@ -3049,11 +3059,21 @@ "example": "1", "description": "The ID of the conversation or review being reported." }, + "user_id": { + "type": "string", + "example": "5", + "description": "Optional ID of the user being reported." + }, "reason": { "type": "string", - "example": "Abusive behavior", + "example": "Others", "description": "The reason for submitting this report." }, + "others": { + "type": "string", + "example": "Spam and malicious links", + "description": "Custom reason string. Used only if reason is 'Others'." + }, "description": { "type": "string", "example": "The worker requested payments off-platform and sent abusive messages.", diff --git a/public/uploads/documents/1780397481_passport_1000099941.jpg b/public/uploads/documents/1780397481_passport_1000099941.jpg new file mode 100644 index 0000000..78cad01 Binary files /dev/null and b/public/uploads/documents/1780397481_passport_1000099941.jpg differ diff --git a/public/uploads/documents/1780902733_passport_1000100671.jpg b/public/uploads/documents/1780902733_passport_1000100671.jpg new file mode 100644 index 0000000..66666c9 Binary files /dev/null and b/public/uploads/documents/1780902733_passport_1000100671.jpg differ diff --git a/public/uploads/documents/1780902733_visa_1000100671.jpg b/public/uploads/documents/1780902733_visa_1000100671.jpg new file mode 100644 index 0000000..66666c9 Binary files /dev/null and b/public/uploads/documents/1780902733_visa_1000100671.jpg differ