/** * Show the tours page filter by destination. * * @return \Illuminate\Http\Response */ public function destination($destination) { $region = ['northern', 'southern', 'central']; if (in_array($destination, $region)) { $destinations = TourDestination::where('region', '=', ucfirst($destination) . ' Vietnam')->get(); $des_array = []; foreach ($destinations as $des) { array_push($des_array, $des->id); } $tours = Tour::whereIn('going_to', $des_array)->orWhereIn('depart_from', $des_array)->published()->get(); return view('vietnam.destination', ['tours' => $tours, 'destination' => ucfirst($destination) . ' Vietnam']); } else { $destination = TourDestination::where('alias', '=', $destination)->first(); if ($destination) { $tours = Tour::where('going_to', $destination->id)->orWhere('depart_from', $destination->id)->published()->get(); return view('vietnam.destination', ['tours' => $tours, 'destination' => $destination->name]); } } }