diff --git a/app/Http/Controllers/ChatController.php b/app/Http/Controllers/ChatController.php index da8d3df..192e721 100644 --- a/app/Http/Controllers/ChatController.php +++ b/app/Http/Controllers/ChatController.php @@ -276,10 +276,22 @@ public function deleteMessage($discussionId, $messageId) if (Message::find($message->id + 10000000)) { $capsule = Message::where('id', $messageId + 10000000)->where('chat_id', $discussionId)->first(); + if ($message->media_url) { + $mediaPath = public_path('source/assets/media/' . $message->media_url); + if (file_exists($mediaPath)) { + unlink($mediaPath); + } + } $capsule->delete(); $message->delete(); } else{ + if ($message->media_url) { + $mediaPath = public_path("/source/media/" . $message->media_url); + if (file_exists($mediaPath)) { + unlink($mediaPath); + } + } $message->delete(); }