acabo de crear un filtro muy sencillo con Ajax y Laravel.
Solo son 4 opciones, el filtro funciona bien, pero cuando dejo ambas fechas vacías, From, To, manda error 500 Internal Server Error
private function searchCierre($from = null, $to = null, $asesor = NULL, $type = NULL )
{
$cierre = Cierre::all();
if($from && $to){
$cierre = Cierre::whereDate('created_at', '>=', $from)
->whereDate('created_at', '<=', $to);
}
if($asesor) {
$cierre = $cierre->where('asesor_id',$asesor);
}
if($type) {
$cierre = $cierre->where('operation_type',$type);
}
return $cierre->paginate(100);
}
No entiendo porqué hace esto, puse todos los argumentos como opcionales en el método, no debería arrojar error
$cierre = Cierre::all();
, sustituyelo porCierre::query()
y debería funcionar