Ejemplo n.º 1
0
 public function sort($sort)
 {
     $id_site = \Session::get('id_site');
     $id_user = $this->auth->user()->id;
     $sitios = Sites::where('id', $id_site)->get();
     $sites = Sites_users::where('id_user', $id_user)->count();
     $sitio_plan = DB::table('sites')->where('id', $id_site)->value('plan');
     $plan = Plans::where('id', $sitio_plan)->get();
     $user_count = DB::table('sites_users')->where('id_site', $id_site)->count();
     $tipos = Cuotas::orderBy('id', 'ASC')->lists('concepto', 'id');
     $users = DB::select('select users.*, sites_users.status, sites_users.role, sites_users.type FROM users JOIN sites_users ON sites_users.id_user = users.id AND sites_users.id_site = :id', ['id' => $id_site]);
     $users = collect($users);
     if ($sort == 'name') {
         $users = $users->sortBy('name');
     } else {
         if ($sort == 'desc') {
             $users = $users->sortByDesc('name');
         } else {
             if ($sort == 'email') {
                 $users = $users->sortBy('email');
             } else {
                 if ($sort == 'email_desc') {
                     $users = $users->sortByDesc('email');
                 } else {
                     if ($sort == 'all') {
                         $users = $users;
                     } else {
                         if ($sort == 'adeudo') {
                             $users = $users->where('status', 0);
                         } else {
                             if ($sort == 'corriente') {
                                 $users = $users->where('status', 1);
                             }
                         }
                     }
                 }
             }
         }
     }
     return view('/admin/usuarios', ['users' => $users, 'tipos' => $tipos, 'user_count' => $user_count, 'plan' => $plan, 'sitios' => $sitios, 'sites' => $sites]);
 }
Ejemplo n.º 2
0
 public function usuarios()
 {
     $id_site = \Session::get('id_site');
     $id_user = $this->auth->user()->id;
     $user_role = Sites_users::where('id_site', $id_site)->where('id_user', $id_user)->value('role');
     $sites = Sites_users::where('id_user', $id_user)->count();
     if ($user_role == 1) {
         $id_site = \Session::get('id_site');
         $sitios = Sites::where('id', $id_site)->get();
         $sitio_plan = DB::table('sites')->where('id', $id_site)->value('plan');
         $plan = Plans::where('id', $sitio_plan)->get();
         $user_count = DB::table('sites_users')->where('id_site', $id_site)->count();
         $users = DB::select('select users.*, sites_users.status, sites_users.role, sites_users.type FROM users JOIN sites_users ON sites_users.id_user = users.id AND sites_users.id_site = :id', ['id' => $id_site]);
         $tipos = Cuotas::where('id_site', $id_site)->lists('concepto', 'id');
         return view('/admin/usuarios', ['users' => $users, 'tipos' => $tipos, 'user_count' => $user_count, 'plan' => $plan, 'sitios' => $sitios, 'sites' => $sites]);
     } else {
         return Redirect::to('home');
     }
 }