feat: add admin controllers

This commit is contained in:
2026-08-17 07:43:47 +03:30
parent f50031393e
commit 8372e20182
12 changed files with 559 additions and 0 deletions
@@ -0,0 +1,47 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Http\Requests\UpdateCommentRequest;
use App\Models\Comment;
class CommentController extends Controller
{
public function index()
{
$comments = Comment::with(['user', 'commentable'])
->latest()
->paginate(15);
return view('admin.comments.index', compact('comments'));
}
public function show(Comment $comment)
{
return view('admin.comments.show', compact('comment'));
}
public function edit(Comment $comment)
{
return view('admin.comments.edit', compact('comment'));
}
public function update(UpdateCommentRequest $request, Comment $comment)
{
$comment->update($request->validated());
return redirect()
->route('admin.comments.index')
->with('success', 'نظر با موفقیت به‌روزرسانی شد.');
}
public function destroy(Comment $comment)
{
$comment->delete();
return redirect()
->route('admin.comments.index')
->with('success', 'نظر با موفقیت حذف شد.');
}
}