diff --git a/app/Http/Controllers/Admin/ReportController.php b/app/Http/Controllers/Admin/ReportController.php index 0a70696..6ad4427 100644 --- a/app/Http/Controllers/Admin/ReportController.php +++ b/app/Http/Controllers/Admin/ReportController.php @@ -5,6 +5,8 @@ use App\Enums\ReportStatus; use App\Http\Controllers\Controller; use App\Models\Report; +use App\Notifications\ReportResolvedNotificationToBroker; +use App\Notifications\ReportRejectedNotificationToUser; use Illuminate\Support\Facades\DB; class ReportController extends Controller @@ -27,9 +29,13 @@ public function resolve(Report $report) $report->status = ReportStatus::Resolved; $report->save(); + $report->user->notify(new ReportRejectedNotificationToUser($report->deals()->first()->title, false)); + $report->deals()->first()->broker->notify(new ReportResolvedNotificationToBroker($report->deals()->first()->title, + false)); + return back()->with('success', 'Report resolved successfully.'); } catch (\Throwable $e) { - \Log::error('Error resolving report', [$report->id, $e->getMessage(), $e->getTraceAsString()]); + \Log::error('Error resolving report', [$report->id, $e->getMessage()]); return back()->with('error', 'Something went wrong.'); } @@ -41,9 +47,11 @@ public function reject(Report $report) $report->status = ReportStatus::Rejected; $report->save(); + $report->user->notify(new ReportRejectedNotificationToUser($report->deals()->first()->title)); + return back()->with('success', 'Report Rejected successfully.'); } catch (\Throwable $e) { - \Log::error('Error rejecting report', [$report->id, $e->getMessage(), $e->getTraceAsString()]); + \Log::error('Error rejecting report', [$report->id, $e->getMessage()]); return back()->with('error', 'Something went wrong.'); } @@ -56,6 +64,11 @@ public function removeContent(Report $report) { try { DB::transaction(function () use ($report) { + + $report->user->notify(new ReportRejectedNotificationToUser($report->deals()->first()->title, true)); + $report->deals()->first()->broker->notify(new ReportResolvedNotificationToBroker($report->deals()->first()->title, + true)); + $deal = $report->deals()->first(); $deal->active = false; $report->status = ReportStatus::Resolved; diff --git a/app/Notifications/ReportRejectedNotificationToUser.php b/app/Notifications/ReportRejectedNotificationToUser.php new file mode 100644 index 0000000..fa77a36 --- /dev/null +++ b/app/Notifications/ReportRejectedNotificationToUser.php @@ -0,0 +1,44 @@ +subject('Update on Your Recent Report: '.$this->dealTitle) + ->greeting('Hello!') + ->line("Thank you for helping us maintain the integrity of our marketplace.") + ->line("We have completed our review of the deal you reported: **{$this->dealTitle}**.") + ->line("Based on our moderation policy, we have rejected your report.") + ->action('View Marketplace', route('explore')) + ->line('Your feedback helps make our community a safer place for everyone.'); + } + + public function toArray($notifiable): array + { + return [ + 'report_outcome' => $this->isContentRemoved ? 'violation_confirmed' : 'no_violation_found', + 'deal_title' => $this->dealTitle + ]; + } +} diff --git a/app/Notifications/ReportResolvedNotificationToBroker.php b/app/Notifications/ReportResolvedNotificationToBroker.php new file mode 100644 index 0000000..ccae8d1 --- /dev/null +++ b/app/Notifications/ReportResolvedNotificationToBroker.php @@ -0,0 +1,47 @@ +isContentRemoved + ? 'has been removed following a policy review.' + : 'has been reviewed and remains active.'; + + return (new MailMessage) + ->subject('Update Regarding Your Reported Deal: '.$this->dealTitle) + ->greeting('Hello!') + ->line("We are writing to inform you that the report regarding your deal, **{$this->dealTitle}**, has been resolved.") + ->line("Our moderation team has completed their review, and the content {$status}") + ->action('View My Deals', route('broker.dashboard')) // Adjusted for your UMS/Project structure + ->line('Thank you for being a part of our marketplace.'); + } + + public function toArray($notifiable): array + { + return [ + 'deal_title' => $this->dealTitle, + 'action_taken' => $this->isContentRemoved ? 'removed' : 'kept', + ]; + } +} diff --git a/app/Notifications/ReportResolvedNotificationToUser.php b/app/Notifications/ReportResolvedNotificationToUser.php new file mode 100644 index 0000000..5db7871 --- /dev/null +++ b/app/Notifications/ReportResolvedNotificationToUser.php @@ -0,0 +1,48 @@ +isContentRemoved + ? 'has been removed following our investigation.' + : 'will remain active as it was found to be in compliance with our guidelines.'; + + return (new MailMessage) + ->subject('Update on Your Recent Report: '.$this->dealTitle) + ->greeting('Hello!') + ->line("Thank you for helping us maintain the integrity of our marketplace.") + ->line("We have completed our review of the deal you reported: **{$this->dealTitle}**.") + ->line("Based on our moderation policy, the content {$outcome}") + ->action('View Marketplace', route('explore')) + ->line('Your feedback helps make our community a safer place for everyone.'); + } + + public function toArray($notifiable): array + { + return [ + 'report_outcome' => $this->isContentRemoved ? 'violation_confirmed' : 'no_violation_found', + 'deal_title' => $this->dealTitle + ]; + } +}