mirror of
https://github.com/NyaaStudios/nyaabooru.git
synced 2025-12-10 05:42:58 +00:00
49 lines
900 B
PHP
49 lines
900 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Comment;
|
|
use App\Models\Post;
|
|
use App\Models\Tag;
|
|
use App\Models\TagGroup;
|
|
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');
|
|
}
|
|
|
|
public function deleteTag(Tag $tag)
|
|
{
|
|
$tag->delete();
|
|
return redirect()->route('tags.home');
|
|
}
|
|
|
|
public function deleteTagGroup(TagGroup $tagGroup)
|
|
{
|
|
foreach ($tagGroup->tags as $tag)
|
|
{
|
|
$tag->delete();
|
|
}
|
|
$tagGroup->delete();
|
|
return redirect()->route('tags.groups');
|
|
}
|
|
}
|