My search function is not returning the results I expect.
How can I output the query object to see what is returned by the db query?
public function search()
{
//Save requests to variables
$price = Helper::explodeString(Request::get('price'));
$texts = Helper::explodeString(Request::get('texts'));
$minutes = Helper::explodeString(Request::get('minutes'));
$data = Helper::explodeString(Request::get('data'));
$contract = Request::get('contract');
$phone_option = Request::get('phone-option');
//get all selected carriers
$carriers = array();
foreach(Carrier::all() as $carrier){
if(Request::has($carrier->name)){
$carriers[] = $carrier->id;
}
}
// build query
$query = Plan::whereBetween('price', $price)
->whereBetween('text', $texts)
->whereBetween('minutes', $minutes)
->whereBetween('data', $data)
->whereIn('carrier', $carriers)
->where('contract', $contract)
->where('phone_inlcuded', $phone_option);
return view('planresults')->with('plans', $query);
}
I am then trying to output the object into my view as follows
@foreach($plans as $plan)
<div class="panel price">
<div class="panel-heading arrow_box text-center">
<h3>{{$plan->Carrier->name}}</h3>
<h3>{{$plan->name}}</h3>
</div>
<div class="panel-body text-center">
<p class="lead" style="font-size:40px"><strong>${{$plan->price}} / month</strong></p>
</div>
<ul class="list-group list-group-flush text-center">
<li class="list-group-item">{{$plan->Carrier->name}}</li>
<li class="list-group-item">{{$plan->contract}} Month term contract</li>
@if($plan->phone_included == 0)
<li class="list-group-item">No phone included</li>
@else
<li class="list-group-item">Phone option included</li>
@endif
</ul>
<div class="panel-footer">
<a class="btn btn-lg btn-block btn-success" href="{{$plan->url}}">BUY NOW!</a>
</div>
</div>
<!-- /PRICE ITEM -->
@endforeach
No results are being displayed in my view so I assume my object is empty... I'm very confused and have been stuck on this for ages now