예제 #1
0
 public function getConfiguracion($idEquipment = null, $idCustomer = null)
 {
     $dataHotspots = Hostpots::find($idEquipment);
     if ($idCustomer == null) {
         $idCustomer = Auth::customer()->user()->id;
     }
     $dataCampania = Campania::whereCustomerId($idCustomer)->get()->toArray();
     if ($dataHotspots->geocode == 0) {
         $typeCampania = Campania::where('flagactive', '=', '1')->whereCustomerId(null)->lists('name', 'id');
     } else {
         if ($idCustomer == null) {
             $idCustomer = Auth::customer()->user()->id;
         }
         $typeCampania = Campania::where('flagactive', '=', '1')->whereCustomerId($idCustomer)->lists('name', 'id');
     }
     $datos = HotspotsCampania::join('campania as c', 'c.id', '=', 'hotspots_campania.campania_id')->select('hotspots_campania.day_id')->where('hotspots_campania.hotspots_id', '=', $idEquipment)->get()->toArray();
     foreach ($datos as $value) {
         $days[] = $value['day_id'];
     }
     $day = Day::all();
     foreach ($day as $d) {
         $checked = isset($days) ? in_array($d->id, $days) : false;
         if ($checked) {
             $datos = HotspotsCampania::join('campania as c', 'c.id', '=', 'hotspots_campania.campania_id')->select('c.*', 'hotspots_campania.*')->where('hotspots_campania.hotspots_id', '=', $idEquipment)->where('hotspots_campania.day_id', '=', $d->id)->first();
             $d->campania_id = $datos->campania_id;
             $d->campania_name = $datos->name;
             $d->campania_imagen = $datos->imagen;
         }
     }
     return viewc('client.' . self::NAMEC . '.configuracion', compact('idEquipment', ['datos', 'dataCampania', 'day', 'idCustomer']), ['typeCampania' => $typeCampania]);
 }