Hi. I'm trying to search users using scopes but when trying to search for all, it only returns the wrong data. I.e I have in the searches form a checkbox with "All" "Active" "in-Active" but if I choose all it returns only the active for some reason.
Either make your all_statuses button toggle all other checkboxes or give it a different value.
and change your query to whereIn:
public function scopeHasStatus($query, $status_id)
{
if (!$status_id) {
return $query;
}
return $query->whereHas('account', function ($query) use ($status_id) {
$query->whereIn('status_id', $status_id);
});
}