I found a lot of similar questions but without a real solution for me.
I have a project on Laravel 5.4
Now, in my Controller I am preparing filters for my search.
So, Imagine that I want to filter my search by "location", and "about" fields of my Cv
model.
So, I am finding distinct values of each one doing this
$arrOfTags = explode(',', $request['position']);
//separate basic search request(using some js modules that return a request with "," separator.
//Basically, find a Cv where location of "positions" is distinct
$filter0 = Cv::select('location')
->whereIn('position', $arrOfTags)
->groupBy('location')
->get();
$filter1 = Cv::select('about')
->whereIn('position', $arrOfTags)
->groupBy('about')
->get();
Now, I want to concatinate this 2 results in object named $filters
And then, in my Blade to use it like :
@foreach($filters as $filter)
<li> <input type="checkbox" name="location" value="{{$filter->location}}"/> <span> {{$filter->location}} </span> </li>
@endforeach
@foreach($filters as $filter)
<li> <input type="checkbox" name="location" value="{{$filter->about}}"/> <span> {{$filter->about}} </span> </li>
@endforeach
I tried array_merge of objects, creating a new empty object and set parameters of this objects and other stuff, but without success.