/** * Display a listing of the resource. * * @return Response */ public function index($route) { if (LaravelLocalization::getCurrentLocale() == 'en') { $audience = Audience::where('route_en', $route)->first(); $audiences = Audience::all(); return view('audiences.' . $route . '.index')->with(['audience' => $audience, 'audiences' => $audiences]); } elseif (LaravelLocalization::getCurrentLocale() == 'nl') { $audience = Audience::where('route_nl', $route)->first(); $audiences = Audience::all(); return view('audiences.' . $audience->route_en . '.index')->with(['audience' => $audience, 'audiences' => $audiences]); } }
public function getAllSearchResults() { $searchterm = Input::get('keyword'); if (strlen($searchterm) >= 3) { $posts = Post::where('slug_nl', 'LIKE', '%' . $searchterm . '%')->orWhere('slug_en', 'LIKE', '%' . $searchterm . '%')->orWhere('slug_fr', 'LIKE', '%' . $searchterm . '%')->orWhere('name_nl', 'LIKE', '%' . $searchterm . '%')->orWhere('name_en', 'LIKE', '%' . $searchterm . '%')->orWhere('name_fr', 'LIKE', '%' . $searchterm . '%')->orWhere('subtitle_nl', 'LIKE', '%' . $searchterm . '%')->orWhere('subtitle_en', 'LIKE', '%' . $searchterm . '%')->orWhere('subtitle_fr', 'LIKE', '%' . $searchterm . '%')->orWhere('text_nl', 'LIKE', '%' . $searchterm . '%')->orWhere('text_en', 'LIKE', '%' . $searchterm . '%')->orWhere('text_fr', 'LIKE', '%' . $searchterm . '%')->orWhere('bullets_nl', 'LIKE', '%' . $searchterm . '%')->orWhere('bullets_en', 'LIKE', '%' . $searchterm . '%')->orWhere('bullets_fr', 'LIKE', '%' . $searchterm . '%')->orWhere('location_nl', 'LIKE', '%' . $searchterm . '%')->orWhere('location_en', 'LIKE', '%' . $searchterm . '%')->orWhere('location_fr', 'LIKE', '%' . $searchterm . '%')->orWhere('price', 'LIKE', '%' . $searchterm . '%')->get(); foreach ($posts as $post) { $audiences = explode(",", $post->audiences); $post->audiences = ""; for ($i = 0; $i < count($audiences); $i++) { $post->audiences = substr_replace($post->audiences . Audience::where('id', $audiences[$i])->first()->name_en . ", ", "", -1); } } $results = Offer::where('name_nl', 'LIKE', '%' . $searchterm . '%')->orWhere('name_en', 'LIKE', '%' . $searchterm . '%')->orWhere('name_fr', 'LIKE', '%' . $searchterm . '%')->orWhere('description_nl', 'LIKE', '%' . $searchterm . '%')->orWhere('description_en', 'LIKE', '%' . $searchterm . '%')->orWhere('description_fr', 'LIKE', '%' . $searchterm . '%')->orWhere('bullets_nl', 'LIKE', '%' . $searchterm . '%')->orWhere('bullets_en', 'LIKE', '%' . $searchterm . '%')->orWhere('bullets_fr', 'LIKE', '%' . $searchterm . '%')->get(); if (LaravelLocalization::getCurrentLocale() == 'en') { foreach ($results as $result) { $result->audiences = Audience::where('id', $result->audience_id)->first()->name_en; } } elseif (LaravelLocalization::getCurrentLocale() == 'nl') { foreach ($results as $result) { $result->audiences = Audience::where('id', $result->audience_id)->first()->name_nl; } } $results = array_merge($results->all(), $posts->all()); return $results; } else { return null; } }