public function query() { $query = Input::get('estabelecimento'); $searchValues = preg_split('/\\s+/', $query); // split on 1+ whitespace //municipios $municipios = \App\Municipio::where(function ($q) use($searchValues) { foreach ($searchValues as $value) { $q->where('nome', 'like', "%{$value}%"); } })->limit(4)->get(); //estabelecimentos $estabelecimentos = \App\Estabelecimento::where(function ($q) use($searchValues) { foreach ($searchValues as $value) { $q->where('no_fantasia', 'like', "%{$value}%"); } })->join('municipios', 'municipios.co_municipio', '=', 'estabelecimentos.co_municipio')->limit(4)->get(); return array_merge($estabelecimentos->toArray(), $municipios->toArray()); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $convenio = \App\Convenio::findOrFail($id); $estabelecimentos = \App\Estabelecimento::where('est_tipo', 'ct')->get(); return View('convenio.edit', ['convenio' => $convenio, 'estabelecimentos' => $estabelecimentos]); }