That’s no problem:
// add the filter
if(!empty(param('filter'))) {
$filter = str::slug(param('filter'));
$projects = $projects->filter(function($project) use($filter) {
// split tags and convert to lowercase
$secretTags = array_map('str::slug', $project->filter()->split(','));
$officialTags = array_map('str::slug', $project->job()->split(','));
// check if one of the fields contains the tag
if(in_array($filter, $secretTags)) return true;
if(in_array($filter, $officialTags) && $project->isVisible()) return true;
// neither field contains the tag
return false;
});
} else {
$projects = new Pages(array($projects_portfolio_featured, $projects_side_featured));
}
return compact('projects', 'filters', 'filter');