public function offerShow($offer)
 {
     if (Agent::isMobile()) {
         $offer = Offer::active()->identifier($offer)->whereHas('websites', function ($q) {
             $q->where('id', $this->website_id);
         })->with(['contents' => function ($query) {
             $query->where('lang_id', '=', $this->langId);
         }])->orderBy('priority', 'desc')->first();
     } else {
         $offer = Offer::active()->identifier($offer)->whereHas('websites', function ($q) {
             $q->where('id', $this->website_id);
         })->with(['contents' => function ($query) {
             $query->where('lang_id', '=', $this->langId);
         }])->where('mobile_only', 0)->orderBy('priority', 'desc')->first();
     }
     if ($offer) {
         $travel_window = App\OfferTravelWindow::where('offer_id', $offer->id)->orderBy('start_date', 'asc')->get();
         $resorts = Resort::active()->whereHas('offers', function ($q) use($offer) {
             $q->where('id', $offer->id);
         })->with(['contents' => function ($query) {
             $query->where('lang_id', '=', $this->langId);
         }])->get();
         $offer_resort = App\OfferResort::where('offer_id', $offer->id)->get();
         $i = 0;
         foreach ($resorts as $key => $value) {
             //offer_resort2 almacena los datos necesarios en un solo vector para llevar al formulario.
             for ($k = 0; $k < count($offer_resort); $k++) {
                 if ($value->id == $offer_resort[$k]['resort_id']) {
                     $offer_resort2[$i]['ihotelier_rate_id'] = $offer_resort[$k]['ihotelier_rate_id'];
                     $offer_resort2[$i]['minimum'] = $offer_resort[$k]['minimum'];
                     $offer_resort2[$i]['id'] = $value->id;
                     $offer_resort2[$i]['name'] = $value->name;
                     $offer_resort2[$i]['ihotelier_id'] = $value->ihotelier_id;
                     $offer_resort2[$i]['area'] = $value->area;
                 }
             }
             $i++;
         }
         $all_offers = Offer::active()->range()->whereHas('resorts', function ($q) use($resorts) {
             $q->where('id', $resorts[0]->id);
         })->whereHas('websites', function ($q) {
             $q->where('id', $this->website_id);
         })->with(['contents' => function ($query) {
             $query->where('lang_id', '=', $this->langId);
         }])->where('mobile_only', 0)->orderBy('priority', 'desc')->get()->take(3);
         return View('pages.offer ', compact('offer', 'resorts', 'all_offers', 'offer_resort2', 'travel_window'));
     } else {
         abort(404);
     }
 }
 public function offerShow($offer)
 {
     if (Agent::isMobile()) {
         $offer = Offer::active()->identifier($offer)->whereHas('websites', function ($q) {
             $q->where('id', $this->website_id);
         })->with(['contents' => function ($query) {
             $query->where('lang_id', '=', $this->langId);
         }])->orderBy('priority', 'desc')->first();
     } else {
         $offer = Offer::active()->identifier($offer)->whereHas('websites', function ($q) {
             $q->where('id', $this->website_id);
         })->with(['contents' => function ($query) {
             $query->where('lang_id', '=', $this->langId);
         }])->where('mobile_only', 0)->first();
     }
     if ($offer) {
         $resorts = Resort::active()->whereHas('offers', function ($q) use($offer) {
             $q->where('id', $offer->id);
         })->with(['contents' => function ($query) {
             $query->where('lang_id', '=', $this->langId);
         }])->get();
         $all_offers = Offer::active()->range()->whereHas('resorts', function ($q) use($resorts) {
             $q->where('id', $resorts[0]->id);
         })->whereHas('websites', function ($q) {
             $q->where('id', $this->website_id);
         })->with(['contents' => function ($query) {
             $query->where('lang_id', '=', $this->langId);
         }])->where('mobile_only', 0)->orderBy('priority', 'desc')->get()->take(3);
         return View('pages.offer ', compact('offer', 'all_offers'));
     } else {
         abort(404);
     }
 }