12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- namespace App\Services;
- use App\Models\Video;
- use App\Traits\PageTrait;
- class VideoService
- {
- use PageTrait;
- public function getList($condition, $sort = 'rank', $sortable = 'desc')
- {
-
- $query = Video::query();
- $query->select(
- 'id',
- 'name',
- 'cover',
- 'subtitle',
- 'content',
- 'rank',
- 'first_id'
- );
- //->where('platform','psy_center');
- //搜索
- if(isset($condition['keywords']) && $condition['keywords']) {
- $query->where('name', 'like', '%'.$condition['keywords'].'%');
- }
- if(isset($condition['category_id']) && $condition['category_id']) {
- $query->where('first_id', $condition['category_id']);
- }
- if(isset($condition['platform']) && $condition['platform']) {
- $query->where('platform', $condition['platform']);
- }
- if(isset($condition['type']) && $condition['type']) {
- $query->where('type', $condition['type']);
- }
- // $query->where('status', 0);
- //排序
- $query->orderBy($sort, $sortable);
- return self::JsonPage($query);
- }
- }
|