我想验证一个字段,员工可以在该字段中申请假期,该假期按休假类别进行分类。在休假类别中,我指定了日期,当员工从该类别中请求休假时,他不能超过休假类别中指定的总天数,我到目前为止已经尝试过
$startdate = Carbon::parse($request->start_date);
$enddate = Carbon::parse($request->end_date);;
$diff = $startdate->diffInDays($enddate);
$days=LeaveCategory::where('id',$request->category)->first();
'category' =>[
'required',
function($days,$diff,$fail){
if($days->days < $diff){
return $fail("You cant");
}
}],
但是它给了我一个错误,叫做Closure类的Object无法转换为字符串。请帮我解决这个问题