laravel的时间段orm查询

public function payRollList($time)
    {
        $member_phone = Session::get(phone');
        $engineer = Engineer::getEngineerByPhone($member_phone);
        $start=date('Y-m-01',strtotime($time));//获取指定月份的第一天
        $end=date('Y-m-t',strtotime($time)); //获取指定月份的最后一天
        $repair=DB::table('order')
            ->where('repair_user',$engineer['member_id'])
            ->where('order_status',1)
            ->whereBetween('create_time',[strtotime($start),strtotime($end)])
            ->where('status',0)
            ->orderBy('create_time', 'desc')
            ->paginate($this->number);
        return view('home.engineer.payroll_order')->with('phone', $member_phone)->with('repair', $repair);
    }


主要是whereBetween这句。create_time 为mysql的timestamp类型

whereBetween('create_time',[strtotime($start),strtotime($end)])

原文地址:https://www.cnblogs.com/lamp01/p/6914089.html

 

Leave a Reply