@Tray2 The filtering is being done in the above Controller code ->filterDistribution($request)->filterSquema($request) those scopes.
public function scopeFilterDistribution($query, $request) {
$query->when($request->input('district_id'), function ($q, $district) {
$q->where('district_id', $district);
}, function ($query) use ($request) {
$query->when($request->input('canton_id'), function ($query, $canton) {
$query->whereHas('district', function ($query) use ($canton) {
return $query->where('canton_id', $canton);
});
}, function ($query) use ($request) {
$query->when($request->input('province_id'), function ($query, $province) {
$query->whereHas('district.canton', function ($query) use ($province) {
return $query->where('province_id', $province);
});
}, function ($query) use ($request) {
$query->when($request->input('country_id'), function ($query, $country) {
$query->whereHas('district.canton.province', function ($query) use ($country) {
return $query->where('country_id', $country);
});
});
});
});
});
}
public function scopeFilterSquema($query, $request) {
$query->when($request->input('format_id'), function ($query, $format) {
$query->where('format_id', $format);
}, function ($query) use ($request) {
$query->when($request->input('chain_id'), function ($query, $chain) {
$query->whereHas('format', function ($query) use ($chain) {
return $query->where('chain_id', $chain);
});
}, function ($query) use ($request) {
$query->when($request->input('channel_id'), function ($query, $channel) {
$query->whereHas('format.chain', function ($query) use ($channel) {
return $query->where('channel_id', $channel);
});
});
});
});
}
I'm more worried about the Vue aspect of it, because you're right that getting 12k records is fast but the page takes like 5-8 seconds to fully load when I set all the markers on the map at once and it might even take longer, getting the 12k records and loading just the map without the markers is fast.