nyaabooru/app/Http/Controllers/DeletionController.php
2025-05-24 17:01:54 -04:00

22 lines
392 B
PHP

<?php
namespace App\Http\Controllers;
use App\Models\Comment;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class DeletionController extends Controller
{
public function deleteComment(Comment $comment)
{
if (Auth::id() != $comment->user->id)
{
abort(401);
}
$postid = $comment->post->id;
$comment->delete();
return redirect("/posts/$postid");
}
}