private function transformPaginator(Paginator $paginator)
 {
     $array = $paginator->toArray();
     unset($array['data']);
     // Add pagination info
     $current_page = $paginator->getCurrentPage();
     $next_page = min($current_page + 1, $paginator->getLastPage());
     $previous_page = max($current_page - 1, 1);
     $array['next_page'] = $next_page === $current_page ? NULL : $paginator->getUrl($next_page);
     $array['previous_page'] = $previous_page === $current_page ? NULL : $paginator->getUrl($previous_page);
     return $array;
 }
Esempio n. 2
0
 public function DataGrid()
 {
     $users = $this->userRepository->all();
     // dd(get_class($this->groupRepository));
     // print_r($users);
     // dd($users);
     $perPage = 15;
     $currentPage = Input::get('page') - 1;
     $pagedData = array_slice($users, $currentPage * $perPage, $perPage);
     $users = new Paginator($pagedData, $perPage, $currentPage);
     // dd($users);
     $data['total'] = count($users->toArray());
     // dd($users->toArray());
     $datagrab = $users->toArray()['data'];
     foreach ($users as $key => $user) {
         // dd( array_flip( $group->getPermissions()));
         $datagrab[$key]['id'] = $user->hash;
         $datagrab[$key]['permissions'] = implode(",", array_flip($user->getPermissions()));
     }
     $data['rows'] = $datagrab;
     return json_encode($data);
 }