VideoService.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace App\Services;
  3. use App\Models\Video;
  4. use App\Traits\PageTrait;
  5. class VideoService
  6. {
  7. use PageTrait;
  8. public function getList($condition, $sort = 'rank', $sortable = 'desc')
  9. {
  10. $query = Video::query();
  11. $query->select(
  12. 'id',
  13. 'name',
  14. 'cover',
  15. 'subtitle',
  16. 'content',
  17. 'rank',
  18. 'first_id'
  19. );
  20. //->where('platform','psy_center');
  21. //搜索
  22. if(isset($condition['keywords']) && $condition['keywords']) {
  23. $query->where('name', 'like', '%'.$condition['keywords'].'%');
  24. }
  25. if(isset($condition['category_id']) && $condition['category_id']) {
  26. $query->where('first_id', $condition['category_id']);
  27. }
  28. if(isset($condition['platform']) && $condition['platform']) {
  29. $query->where('platform', $condition['platform']);
  30. }
  31. if(isset($condition['type']) && $condition['type']) {
  32. $query->where('type', $condition['type']);
  33. }
  34. // $query->where('status', 0);
  35. //排序
  36. $query->orderBy($sort, $sortable);
  37. return self::JsonPage($query);
  38. }
  39. }