public function restore(Request $request) { Offer::withTrashed()->where('id', $request->id)->restore(); $offer = Offer::find($request->id); $audience = Audience::find($offer->audience_id)->name_nl; $message = "<div class='alert alert-success' role='alert'>\n <span class='fa fa-fw fa-thumbs-o-up'></span> <strong>" . ucfirst($offer->name_nl) . "</strong> werd met succes terug toegevoegd aan het aanbod van <strong>" . ucfirst($audience) . "</strong>!\n </div>"; Session::flash('messages', $message); return redirect('/admin/dashboard/offers'); }
<?php /** * Created by PhpStorm. * User: Evert * Date: 25/09/2015 * Time: 2:14 */ $localizedRoutes = array(); foreach (\Idw\Audience::all() as $audience) { $localizedRoutes[$audience->route_en] = "doelgroepen/" . $audience->route_nl; foreach (\Idw\Offer::where('audience_id', $audience->id)->get() as $offer) { $localizedRoutes[$audience->route_en . "." . $offer->route_en] = "doelgroepen/" . $audience->route_nl . "/" . $offer->route_nl; } } foreach (\Idw\Post::all() as $post) { $localizedRoutes[$post->route_en] = "nieuws/" . $post->route_nl; } foreach (\Idw\Page::all() as $page) { $localizedRoutes[$page->route_en] = "paginas/" . $page->route_nl; } foreach (\Idw\Event::all() as $event) { $localizedRoutes[$event->route_en] = "evenementen/" . $event->route_nl; } return $localizedRoutes;
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; } }