Skip to content

Commit

Permalink
Delete media in folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Saodus committed Dec 17, 2024
1 parent 16c4ccc commit fa3d5c1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/Http/Controllers/ChatController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit fa3d5c1

Please sign in to comment.