|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Manager;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use App\Models\Training;
|
|
|
|
|
|
|
|
|
|
|
|
class TrainingController extends CommonController
|
|
|
|
|
|
{
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @OA\Get(
|
|
|
|
|
|
* path="/manager/get-videos",
|
|
|
|
|
|
* summary="获取视频列表",
|
|
|
|
|
|
* description="获取视频列表",
|
|
|
|
|
|
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
|
|
|
|
|
|
* @OA\Parameter(name="keyword", in="query", @OA\Schema(type="string"), required=false, description="查询关键词"),
|
|
|
|
|
|
* @OA\Parameter(name="page", in="query", @OA\Schema(type="integer"), required=false, description="当前页码,默认为1"),
|
|
|
|
|
|
* @OA\Parameter(name="pageLength", in="query", @OA\Schema(type="integer"), required=false, description="每页数量,默认为5"),
|
|
|
|
|
|
* @OA\Response(
|
|
|
|
|
|
* response="200",
|
|
|
|
|
|
* description="获取视频列表"
|
|
|
|
|
|
* )
|
|
|
|
|
|
* )
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
public function index()
|
|
|
|
|
|
{
|
|
|
|
|
|
$data = (new Training());
|
|
|
|
|
|
if (request()->keyword) {
|
|
|
|
|
|
$keyword = request()->keyword;
|
|
|
|
|
|
$data = $data->where(function ($query) use ($keyword) {
|
|
|
|
|
|
$query
|
|
|
|
|
|
->where("title", "like", "%{$keyword}%")
|
|
|
|
|
|
->orWhereHas("type", function ($query) use ($keyword) {
|
|
|
|
|
|
$query->where("name", "like", "%{$keyword}%");
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
$pageLength = request()->pageLength ? (int)request()->pageLength : 5;
|
|
|
|
|
|
$data = $data->paginate($pageLength);
|
|
|
|
|
|
return response()->json($data->toArray());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|