<?php

namespace App\Http\Controllers\API\H5;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class EntrustController extends Controller
{
    public function GetList(Request $request)
    {



        $searchInfo = request('searchInfo');

        $userid = $request->get('userid');//中间件产生的参数

        $list=DB::table('s_list')
            ->leftJoin('s_period','s_list.reservation_time','=','s_period.id')
            ->leftJoin('s_department_resources','s_list.reservation_sources','=','s_department_resources.id')
            ->select('s_list.*','s_period.period_begin_time','s_period.period_end_time','s_department_resources.department_resources_name')
            ->where(['s_list.is_del'=>0,'s_list.is_nullify'=>0])
            ->where('s_list.reg_num', $userid);
        if ($searchInfo['dateRange']!=null and count($searchInfo['dateRange']) == 2) {
            $list = $list->whereBetween('s_list.entrust_date', $searchInfo['dateRange']);
        }



        $count = $list;
        $count = $count->count();
        $list=$list->orderBy('id', 'desc')->get();



        return \Yz::Return(true,'查询完成',['list'=>$list,'count'=>$count]);
    }

}
