nyaabooru/app/Http/Controllers/DeletionController.php

31 lines
564 B
PHP

<?php
namespace App\Http\Controllers;
use App\Models\Comment;
use App\Models\Post;
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");
}
public function deletePost(Post $post)
{
$post->featured = null;
$post->save();
$post->delete();
return redirect()->route('posts.home');
}
}