feat: add admin controllers
This commit is contained in:
@@ -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', 'نظر با موفقیت حذف شد.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user