CircleMessageRepository.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2019/6/5
  6. * Time: 16:03
  7. */
  8. namespace App\Repositories\Circle;
  9. use App\Models\InterestCircle;
  10. use App\Models\InterestCircleArticle;
  11. use App\Models\InterestCircleMessage;
  12. use App\Models\InterestCircleMessageComment;
  13. use App\Models\InterestCircleUser;
  14. use App\Models\Post;
  15. use Illuminate\Database\QueryException;
  16. use Dingo\Api\Http\Response;
  17. use Illuminate\Support\Carbon;
  18. use Illuminate\Support\Facades\DB;
  19. use Illuminate\Support\Facades\Log;
  20. use Illuminate\Support\Facades\Redis;
  21. class CircleMessageRepository
  22. {
  23. public function __construct(InterestCircle $interestCircle,
  24. InterestCircleMessage $interestCircleMessage,
  25. InterestCircleMessageComment $interestCircleMessageComment
  26. )
  27. {
  28. $this->interestCircle = $interestCircle;
  29. $this->interestCircleMessage = $interestCircleMessage;
  30. $this->interestCircleMessageComment = $interestCircleMessageComment;
  31. }
  32. /**
  33. * 提问列表
  34. */
  35. public function lists($request)
  36. {
  37. $perPage = isset($request['per_page']) ? $request['per_page'] : 20;
  38. $where[] = ['circle_id', $request['id']];
  39. return $this->interestCircleMessage
  40. ->where($where)
  41. ->orderBy('is_recommend', 'desc')
  42. ->orderBy('id', 'desc')
  43. ->paginate($perPage);
  44. }
  45. }