@tykus $model is just a variable number or null. Ehm sorry the real eloquent query is more complex :S
$data_in = request('data_in');
$data_fin = request('data_fin');
$bigcust = request('bigcust'); <= this could be a number or null
$countRifiuti = Refunds::whereHas(
'claims', function ($query) use($bigcust){
$query->where([
['bigcust', '=', $bigcust],
]);
},
)
->where([
['status_ref', '>', 1],
['status_ref', '<', 5],
['date_status', '>=', $data_in],
['date_status', '<=', $data_fin]
])
->count();
Refunds belongs to Claims and Claims hasMany Refunds. How can i apply what u say? thanks