|
|
<?php
|
|
|
|
|
|
namespace App\Http\Controllers\Customer;
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
use App\Models\OrderItems;
|
|
|
use App\Models\Orders;
|
|
|
use App\Models\Project;
|
|
|
use App\Models\Training;
|
|
|
|
|
|
class PublicController extends Controller
|
|
|
{
|
|
|
/**
|
|
|
* @OA\Get(
|
|
|
* path="/customer/get-orders-count",
|
|
|
* summary="V2-获取总服务单数",
|
|
|
* description="获取总服务单数",
|
|
|
* @OA\Response(
|
|
|
* response="200",
|
|
|
* description="获取总服务单数",
|
|
|
* )
|
|
|
* )
|
|
|
*/
|
|
|
public function getOrdersCount() {
|
|
|
$orders_count = Orders::count();
|
|
|
$order_items_count = OrderItems::whereHas("order")->count();
|
|
|
return response()->json(compact("orders_count","order_items_count"));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @OA\Get(
|
|
|
* path="/customer/get-projects",
|
|
|
* summary="V2-获取医院列表",
|
|
|
* description="获取医院列表",
|
|
|
* @OA\Response(
|
|
|
* response="200",
|
|
|
* description="获取医院列表",
|
|
|
* )
|
|
|
* )
|
|
|
*/
|
|
|
|
|
|
public function getProjects()
|
|
|
{
|
|
|
$projects = Project::select("id", "name", "address")->get();
|
|
|
return response()->json($projects->toArray());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @OA\Get(
|
|
|
* path="/customer/get-training-videos",
|
|
|
* summary="V2-获取视频列表",
|
|
|
* description="获取视频列表",
|
|
|
* @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="每页数量,默认为3"),
|
|
|
* @OA\Response(
|
|
|
* response="200",
|
|
|
* description="获取视频列表"
|
|
|
* )
|
|
|
* )
|
|
|
*/
|
|
|
|
|
|
public function getTrainingVideos()
|
|
|
{
|
|
|
$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 : 3;
|
|
|
$data = $data->with(["type" => function ($query) {
|
|
|
$query->select("id", "name");
|
|
|
}])->select("id", "type_id", "title", "poster", "video", "published_at")->orderBy("published_at")->paginate($pageLength);
|
|
|
return response()->json($data->toArray());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @OA\Get(
|
|
|
* path="/customer/get-training-video/{id}",
|
|
|
* summary="V2-获取单条视频数据",
|
|
|
* description="获取单条视频数据",
|
|
|
* @OA\Parameter(name="id", in="path", @OA\Schema(type="integer"), required=true, description="视频内容ID"),
|
|
|
* @OA\Response(
|
|
|
* response="200",
|
|
|
* description="获取单条视频数据"
|
|
|
* )
|
|
|
* )
|
|
|
*/
|
|
|
|
|
|
public function getTrainingVideo($id)
|
|
|
{
|
|
|
$video = Training::with(["type" => function ($query) {
|
|
|
$query->select("id", "name");
|
|
|
}])->select("id", "type_id", "title", "poster", "video", "published_at")->find($id);
|
|
|
|
|
|
return response()->json($video->toArray());
|
|
|
}
|
|
|
|
|
|
}
|