report fix

This commit is contained in:
pavithrak27 2026-06-08 14:01:59 +05:30
parent 42f292c19b
commit 5f67554263
6 changed files with 68 additions and 4 deletions

View File

@ -26,7 +26,9 @@ public function reportFromWorker(Request $request)
$validator = Validator::make($request->all(), [ $validator = Validator::make($request->all(), [
'type' => 'required|in:Chat,Review', 'type' => 'required|in:Chat,Review',
'item_id' => 'required', 'item_id' => 'required',
'user_id' => 'nullable',
'reason' => 'required|string|max:255', 'reason' => 'required|string|max:255',
'others' => 'nullable|string|max:255',
'description' => 'nullable|string|max:2000', 'description' => 'nullable|string|max:2000',
]); ]);
@ -90,17 +92,23 @@ public function reportFromWorker(Request $request)
$reportId = 'REP-' . Str::upper(Str::random(8)); $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 // Insert to moderation_reports
DB::table('moderation_reports')->insert([ DB::table('moderation_reports')->insert([
'id' => $reportId, 'id' => $reportId,
'type' => $request->type, 'type' => $request->type,
'reported_user_id' => $request->user_id,
'reported_user_name' => $reportedName, 'reported_user_name' => $reportedName,
'reported_user_role' => $reportedRole, 'reported_user_role' => $reportedRole,
'reported_user_avatar' => $reportedAvatar, 'reported_user_avatar' => $reportedAvatar,
'reported_by_name' => $worker->name, 'reported_by_name' => $worker->name,
'reported_by_role' => 'Worker', 'reported_by_role' => 'Worker',
'reported_by_avatar' => null, 'reported_by_avatar' => null,
'reason' => $request->reason, 'reason' => $actualReason,
'priority' => 'Medium', 'priority' => 'Medium',
'status' => 'Pending', 'status' => 'Pending',
'description' => $request->description, 'description' => $request->description,
@ -148,7 +156,9 @@ public function reportFromEmployer(Request $request)
$validator = Validator::make($request->all(), [ $validator = Validator::make($request->all(), [
'type' => 'required|in:Chat,Review', 'type' => 'required|in:Chat,Review',
'item_id' => 'required', 'item_id' => 'required',
'user_id' => 'nullable',
'reason' => 'required|string|max:255', 'reason' => 'required|string|max:255',
'others' => 'nullable|string|max:255',
'description' => 'nullable|string|max:2000', 'description' => 'nullable|string|max:2000',
]); ]);
@ -212,17 +222,23 @@ public function reportFromEmployer(Request $request)
$reportId = 'REP-' . Str::upper(Str::random(8)); $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 // Insert to moderation_reports
DB::table('moderation_reports')->insert([ DB::table('moderation_reports')->insert([
'id' => $reportId, 'id' => $reportId,
'type' => $request->type, 'type' => $request->type,
'reported_user_id' => $request->user_id,
'reported_user_name' => $reportedName, 'reported_user_name' => $reportedName,
'reported_user_role' => $reportedRole, 'reported_user_role' => $reportedRole,
'reported_user_avatar' => $reportedAvatar, 'reported_user_avatar' => $reportedAvatar,
'reported_by_name' => $employer->name, 'reported_by_name' => $employer->name,
'reported_by_role' => 'Sponsor', 'reported_by_role' => 'Sponsor',
'reported_by_avatar' => null, 'reported_by_avatar' => null,
'reason' => $request->reason, 'reason' => $actualReason,
'priority' => 'Medium', 'priority' => 'Medium',
'status' => 'Pending', 'status' => 'Pending',
'description' => $request->description, 'description' => $request->description,

View File

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('moderation_reports', function (Blueprint $table) {
$table->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');
});
}
};

View File

@ -1364,11 +1364,21 @@
"example": "1", "example": "1",
"description": "The ID of the conversation or review being reported." "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": { "reason": {
"type": "string", "type": "string",
"example": "Inappropriate messages", "example": "Others",
"description": "The reason for submitting this report." "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": { "description": {
"type": "string", "type": "string",
"example": "The other party sent highly inappropriate and insulting messages.", "example": "The other party sent highly inappropriate and insulting messages.",
@ -3049,11 +3059,21 @@
"example": "1", "example": "1",
"description": "The ID of the conversation or review being reported." "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": { "reason": {
"type": "string", "type": "string",
"example": "Abusive behavior", "example": "Others",
"description": "The reason for submitting this report." "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": { "description": {
"type": "string", "type": "string",
"example": "The worker requested payments off-platform and sent abusive messages.", "example": "The worker requested payments off-platform and sent abusive messages.",

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 KiB