CommentController.php 791 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Http\Controllers\Controller;
  4. use Illuminate\Http\Request;
  5. use App\Models\Comment;
  6. class CommentController extends Controller
  7. {
  8. //
  9. public function index()
  10. {
  11. //
  12. $comments = Comment::where('is_approved', false)->latest()->get();
  13. return view('admin.comments.index', compact('comments'));
  14. }
  15. public function approve(Comment $comment)
  16. {
  17. //
  18. $comment->update([
  19. 'is_approved' => true,
  20. ]);
  21. return back()->with('success', 'Комментарий одобрен!');
  22. }
  23. public function destroy(Comment $comment)
  24. {
  25. //
  26. $comment->delete();
  27. return back()->with('success', 'Комментарий удален!');
  28. }
  29. }