Просмотр файла app/Http/Controllers/Load/NewController.php

Размер файла: 1.11Kb
  1. <?php
  2.  
  3. declare(strict_types=1);
  4.  
  5. namespace App\Http\Controllers\Load;
  6.  
  7. use App\Http\Controllers\Controller;
  8. use App\Models\Comment;
  9. use App\Models\Down;
  10. use Illuminate\View\View;
  11.  
  12. class NewController extends Controller
  13. {
  14. /**
  15. * Новые файлы
  16. *
  17. * @return View
  18. */
  19. public function files(): View
  20. {
  21. $downs = Down::query()
  22. ->where('active', 1)
  23. ->orderByDesc('created_at')
  24. ->with('category', 'user')
  25. ->paginate(setting('downlist'));
  26.  
  27. return view('loads/new_files', compact('downs'));
  28. }
  29.  
  30. /**
  31. * Новые комментарии
  32. *
  33. * @return View
  34. */
  35. public function comments(): View
  36. {
  37. $comments = Comment::query()
  38. ->select('comments.*', 'title', 'count_comments')
  39. ->where('relate_type', Down::$morphName)
  40. ->leftJoin('downs', 'comments.relate_id', 'downs.id')
  41. ->orderByDesc('comments.created_at')
  42. ->with('user')
  43. ->paginate(setting('comments_per_page'));
  44.  
  45. return view('loads/new_comments', compact('comments'));
  46. }
  47. }