This is the solution I've come up with so far, but I don't really like it
$field = Input::get('field');
if ($field === 'item' || $field === 'sku'){
$items = LineItem::where($field, 'LIKE', '%'.Input::get('val').'%')->get();
$ids = [];
foreach ($items as $item) {
$ids[] = $item->order_id;
}
$orders = Order::with('item')->whereIn('id', $ids)->get();
} else {
$orders = Order::with('item')->where($field, Input::get('val'))->get();
}
return View::make('searchPost', ['voters' => $voters]);
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community