View file app/Http/Controllers/Forum/NewController.php

File size: 1.04Kb
  1. <?php
  2.  
  3. declare(strict_types=1);
  4.  
  5. namespace App\Http\Controllers\Forum;
  6.  
  7. use App\Http\Controllers\Controller;
  8. use App\Models\Post;
  9. use App\Models\Topic;
  10. use Illuminate\View\View;
  11.  
  12. class NewController extends Controller
  13. {
  14. /**
  15. * Вывод тем
  16. *
  17. * @return View
  18. */
  19. public function topics(): View
  20. {
  21. $topics = Topic::query()
  22. ->orderByDesc('updated_at')
  23. ->with('forum', 'user', 'lastPost.user')
  24. ->limit(100)
  25. ->get()
  26. ->all();
  27.  
  28. $topics = paginate($topics, setting('forumtem'));
  29.  
  30. return view('forums/new_topics', compact('topics'));
  31. }
  32.  
  33. /**
  34. * Вывод сообшений
  35. *
  36. * @return View
  37. */
  38. public function posts(): View
  39. {
  40. $posts = Post::query()
  41. ->orderByDesc('created_at')
  42. ->with('topic', 'user')
  43. ->limit(100)
  44. ->get()
  45. ->all();
  46.  
  47. $posts = paginate($posts, setting('forumpost'));
  48.  
  49. return view('forums/new_posts', compact('posts'));
  50. }
  51. }