コード例 #1
0
ファイル: GroupsController.php プロジェクト: josmel/hostpots
 public function groupsDataTable(Request $request)
 {
     $idCustomer = $request->input('idCustomer', Auth::customer()->user()->id);
     if ($idCustomer == Auth::customer()->user()->id) {
         $name = 'email_owner';
     } else {
         $name = 'mac';
     }
     $Groups = new Groups();
     $groups = $Groups->getGroupsDataTable($idCustomer);
     foreach ($groups as $value) {
         $dd = DB::select("select group_concat(H.{$name}, concat('*',H.id)) as hotspots from hotspots_groups as HG " . "inner join hotspots as H ON H.id=HG.hotspots_id inner join groups as G ON G.id=HG.groups_id " . "where  HG.flagactive=1 and G.flagactive=1 and HG.groups_id=G.id and HG.groups_id={$value->id} " . "group by G.id ");
         if (isset($dd[0]->hotspots)) {
             $value->hotspots = $dd[0]->hotspots;
         } else {
             $value->hotspots = null;
         }
     }
     return Datatables::of($groups)->editColumn('hotspots', function ($groups) {
         $str = "";
         if ($groups->hotspots == null) {
             $cad = "No asignado";
         } else {
             $data = explode(",", $groups->hotspots);
             $cad = "";
             foreach ($data as $row) {
                 $row = explode('*', $row);
                 $cad = $cad . '<span class="tag-exercise" data-id=' . $row[1] . '>' . $row[0] . '<i class="icon icon-remove"></i></span>';
                 $str = $str . $row[1] . ",";
             }
             $str = substr($str, 0, strlen($str) - 1);
         }
         return $cad . "<span class='more-exercise' data-id='" . $groups->id . "' data-exercises ='" . $str . ",0'> + </span>";
     })->make(true);
 }