Files
shahrzadzandi09/app/Http/Controllers/admin/CommentController.php
T

44 lines
1.0 KiB
PHP

<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Http\Requests\CommentUpdateRequest;
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 update(CommentUpdateRequest $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', 'نظر با موفقیت حذف شد.');
}
}