Просмотр файла app/Repositories/FileRepository.php

Размер файла: 935B
  1. <?php
  2.  
  3. declare(strict_types=1);
  4.  
  5. namespace App\Repositories;
  6.  
  7. use App\Models\File;
  8. use App\Models\Guestbook;
  9. use MotorORM\Collection;
  10.  
  11. class FileRepository implements RepositoryInterface
  12. {
  13. /**
  14. * @param int $id
  15. *
  16. * @return Guestbook|null
  17. */
  18. public function getById(int $id): ?File
  19. {
  20. return File::query()->find($id);
  21. }
  22.  
  23. /**
  24. * @param int $userId
  25. * @param int $storyId
  26. *
  27. * @return Collection<File>
  28. */
  29. public function getFiles(int $userId, int $storyId): Collection
  30. {
  31. return File::query()
  32. ->where('user_id', $userId)
  33. ->where('story_id', $storyId)
  34. ->get();
  35. }
  36.  
  37. /**
  38. * @param int $storyId
  39. *
  40. * @return Collection<File>
  41. */
  42. public function getFilesByStoryId(int $storyId): Collection
  43. {
  44. return File::query()
  45. ->where('story_id', $storyId)
  46. ->get();
  47. }
  48. }