我在laravel工作。
如何计算此条件。我下面的代码请检查
$keyWithData = DB::table('leave_allocations')
->select('employee','leave_type','name')
->where('leave_allocations.from_date','<=',$dateS->format('Y-m-d')." 00:00:00")
->where('leave_allocations.to_date','>=',$dateS->format('Y-m-d')." 00:00:00")
->where('leave_allocations.from_date','<=',$dateE)
->where('leave_allocations.to_date','>=',$dateE)
->where('leave_allocations.employee',$empdata->name)
->where('leave_allocations.leave_type',$type)
->first();
谢谢
答案 0 :(得分:0)
您应该尝试以下操作:
$keyWithData = DB::table('leave_allocations')
->select('employee','leave_type','name')
->whereDate('leave_allocations.from_date', '<=', date('Y-m-d H:i:s',$dateS))
->whereDate('leave_allocations.to_date', '>=', date('Y-m-d H:i:s',$dateS))
->whereDate('leave_allocations.from_date', '<=', date('Y-m-d H:i:s',$dateE))
->whereDate('leave_allocations.to_date', '>=', date('Y-m-d H:i:s',$dateE))
->where('leave_allocations.employee',$empdata->name)
->where('leave_allocations.leave_type',$type)
->first();