PHP Method User::count, codiad Code Examples

This page contains top rated real world PHP examples of method User::count from package codiad extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: AdminController.php Project: thunderclap560/quizkpop
0
 public function index()
 {
     $totalQuizzesCount = Quiz::count();
     $totalUsersCount = User::count();
     $todayQuizzesCount = Quiz::whereRaw('DATE(created_at) = DATE(NOW())')->count();
     $todayUsersCount = User::whereRaw('DATE(created_at) = DATE(NOW())')->count();
     $overallActivities = QuizUserActivity::groupBy('type')->havingRaw("type in ('attempt', 'share')")->select('type', DB::raw('count(*) as count'))->get()->toArray();
     $overallStats = array();
     foreach ($overallActivities as $activity) {
         $overallStats[$activity['type']] = $activity['count'];
     }
     $overallStats['quizzes'] = $totalQuizzesCount;
     $overallStats['users'] = $totalUsersCount;
     $todayActivities = QuizUserActivity::whereRaw('DATE(created_at) = DATE(\'' . date('Y-m-d H:i:s') . '\')')->groupBy('type')->havingRaw("type in ('attempt', 'share')")->select('type', DB::raw('count(*) as count'))->get()->toArray();
     $todayStats = array();
     foreach ($todayActivities as $activity) {
         $todayStats[$activity['type']] = $activity['count'];
     }
     $todayStats['quizzes'] = $todayQuizzesCount;
     $todayStats['users'] = $todayUsersCount;
     //Filling stats vars that are not yet set
     self::fillNullStats($todayStats);
     self::fillNullStats($overallStats);
     View::share(array('overallStats' => $overallStats, 'todayStats' => $todayStats));
     $last30DaysActivity = self::getLastNDaysActivity(30, 'attempt');
     $last30DaysUserRegistrations = self::getLastNDaysUserRegistrations(30);
     View::share(array('last30DaysActivity' => json_encode($last30DaysActivity), 'last30DaysUserRegistrations' => json_encode($last30DaysUserRegistrations)));
     return View::make('admin/index');
 }
Example #2
Show file File: UserController.php Project: visavi/rotorcms
0
 /**
  * Список пользователей
  */
 public function index()
 {
     $list = Request::input('list', 'all');
     $login = Request::input('login');
     if (Request::isMethod('post')) {
         $users = User::all(array('select' => 'login', 'order' => 'point DESC, login ASC'));
         foreach ($users as $key => $val) {
             if (strtolower($login) == strtolower($val->login)) {
                 $position = $key + 1;
             }
         }
         if (isset($position)) {
             $page = ceil($position / Setting::get('users_per_page'));
             App::setFlash('success', 'Позиция в рейтинге: ' . $position);
             App::redirect("/users?page={$page}&login={$login}");
         } else {
             App::setFlash('danger', 'Пользователь с данным логином не найден!');
         }
     }
     $count['users'] = $total = User::count();
     $count['admins'] = User::count(['conditions' => ['level in (?)', ['moder', 'admin']]]);
     $condition = [];
     if ($list == 'admins') {
         $total = $count['admins'];
         $condition = ['level IN(?)', ['moder', 'admin']];
     }
     $page = App::paginate(Setting::get('users_per_page'), $total);
     $users = User::all(array('conditions' => $condition, 'offset' => $page['offset'], 'limit' => $page['limit'], 'order' => 'point DESC, login ASC'));
     App::view('users.index', compact('users', 'page', 'count', 'list', 'login'));
 }
Example #3
Show file File: UserControllerTest.php Project: scottdavis/pearfarm_channel_server
0
 public function testDeleteUser()
 {
     $count = User::count();
     $this->delete('delete', array(), array('id' => $this->user->id), array('user' => $this->user->id));
     $this->assertEquals($count - 1, User::count(array('cache' => false)));
     $this->assertRedirect('http://' . DOMAIN);
 }
Example #4
Show file File: usuarios.php Project: ricardocasares/Cobros
0
 public function filter()
 {
     $string = '%' . $this->input->post('string') . '%';
     $a = array();
     if ($string) {
         $a = User::find('all', array('conditions' => array('nombre LIKE ? OR apellido LIKE ? OR usuario LIKE ?', $string, $string, $string)));
     } else {
         $a = User::find('all');
     }
     $this->table->set_heading('Usuario', 'Nombre', 'Apellido', 'Teléfono', 'Celular', 'Email', 'Dirección', 'Acciones');
     foreach ($a as $al) {
         $this->table->add_row($al->usuario, $al->nombre, $al->apellido, $al->telefono, $al->celular, $al->email, $al->direccion, anchor('usuarios/ver/' . $al->id, img('static/img/icon/doc_lines.png'), 'class="tipwe" title="Ver detalles de usuario"') . ' ' . anchor('usuarios/editar/' . $al->id, img('static/img/icon/pencil.png'), 'class="tipwe" title="Editar usuario"') . ' ' . anchor('usuarios/eliminar/' . $al->id, img('static/img/icon/trash.png'), 'class="tipwe eliminar" title="Eliminar usuario"'));
     }
     echo $this->table->generate();
     $config['base_url'] = site_url('usuarios/index');
     $config['total_rows'] = User::count();
     $config['per_page'] = '10';
     $config['num_links'] = '10';
     $config['first_link'] = '← primero';
     $config['last_link'] = 'último →';
     $this->load->library('pagination', $config);
     echo '<div class="pagination">';
     echo $this->pagination->create_links();
     echo '</div>';
 }
Example #5
Show file File: IndexAction.php Project: jerrylsxu/yiifcms
0
 public function run()
 {
     $model = new User();
     //审核状态
     $user_status = array('all' => '所有', User::STATUS_AUDIT => '待审核', User::STATUS_DISABLE => '禁用', User::STATUS_NORMAL => '正常');
     //条件
     $criteria = new CDbCriteria();
     $groupid = intval(Yii::app()->request->getParam('groupid'));
     $username = trim(Yii::app()->request->getParam('username'));
     $status = Yii::app()->request->getParam('status', 'all');
     $groupid > 0 && $criteria->addColumnCondition(array('groupid' => $groupid));
     if ($status != 'all') {
         $criteria->addSearchCondition('status', $status);
     }
     $criteria->addSearchCondition('username', $username);
     $criteria->order = 'uid ASC';
     $count = $model->count($criteria);
     //分页
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $pages->applyLimit($criteria);
     //查询
     $result = $model->findAll($criteria);
     $this->controller->render('index', array('datalist' => $result, 'pagebar' => $pages, 'status' => $status, 'user_status' => $user_status));
 }
Example #6
Show file File: statistic_controller.php Project: boulama/DreamVids
0
 public function index($request)
 {
     $data = [];
     $counts = [];
     $counts['videos'] = Video::count();
     $counts['users'] = User::count();
     $counts['channels'] = UserChannel::count();
     $counts['comments'] = Comment::count();
     $counts['total_views'] = Video::sumViews();
     $counts['channel_user_ratio'] = round($counts['channels'] / $counts['users'], 2);
     $counts['videos_that_has_comments'] = Statistic::countVideosHavingComments();
     $counts['channels_having_videos'] = Video::find_by_sql('SELECT count(DISTINCT poster_id) as count from `videos`')[0]->count;
     $counts['part_of_commented_videos'] = round($counts['videos_that_has_comments'] / $counts['videos'] * 100, 2);
     $counts['part_of_channels_having_videos'] = round($counts['channels_having_videos'] / $counts['channels'] * 100, 2);
     $counts['user_1_channel'] = Statistic::countUserHavingChannels('= 1');
     $counts['user_2_channel'] = Statistic::countUserHavingChannels('= 2');
     $counts['user_3_channel'] = Statistic::countUserHavingChannels('= 3');
     $counts['user_more3_channel'] = Statistic::countUserHavingChannels('> 3');
     $counts['user_1_channel_part'] = round($counts['user_1_channel'] / $counts['users'] * 100, 2);
     $counts['user_2_channel_part'] = round($counts['user_2_channel'] / $counts['users'] * 100, 2);
     $counts['user_3_channel_part'] = round($counts['user_3_channel'] / $counts['users'] * 100, 2);
     $counts['user_more3_channel_part'] = round($counts['user_more3_channel'] / $counts['users'] * 100, 2);
     $data['counts'] = $counts;
     return new ViewResponse('admin/statistic/index', $data);
 }
Example #7
Show file File: Users.php Project: smilexx/counter
0
 public function init($id_tovar)
 {
     $data = $_REQUEST;
     $join = "INNER JOIN koncentrator_tovarishestvo c ON(user.concetrator = c.name_konc)";
     $this->_Users = User::all(array('conditions' => array("is_admin <> ? and id_tovar= ?", 1, $id_tovar), 'joins' => $join));
     $this->id_tovar = $id_tovar;
     /* if (!isset($data[Users::PAGE])) {
               $this->_Users = User::find('all', array('limit' => 2), array('conditions' => "is_admin <> 1"));
               //var_dump($_Users);
               } else {
     
     
               $this->_Users = User::find('all', array('conditions' => "is_admin <> 1", 'limit' => 2, 'offset' => (($data[Users::PAGE] * 2) - 2)));
               //var_dump($_Users);
               } */
     $this->countPage = ceil(User::count(array('conditions' => "is_admin <> 1")) / 2);
     if (isset($data[self::BUTTON_DELETE])) {
         $User = User::find_by_login($data['login']);
         if ($User instanceof User) {
             $User->delete();
             Flight::redirect('/admin/users/' . $this->id_tovar . '?success=3');
         }
     }
     if (isset($data['saveUser'])) {
         if ($data['idUser'] === 'newUser') {
             return $this->addNewUser();
         } else {
             return $this->changeUser();
         }
     }
 }
Example #8
Show file File: RoleController.php Project: tanmuhittin/rolemanager
0
 public function getUsers(Request $request)
 {
     $yetkiler = Role::all();
     $count = $request->get('count');
     $page = $request->get('page');
     $filters = $request->get('filter');
     $sorting = $request->get('sorting');
     $results = new User();
     if (is_array($filters)) {
         foreach ($filters as $key => $filter) {
             $results = $results->where($key, 'like', "%" . urldecode($filter) . "%");
         }
     }
     if (is_array($sorting)) {
         foreach ($sorting as $key => $sort) {
             $results = $results->orderBy($key, $sort);
         }
     } else {
         $results = $results->orderBy('id', 'desc');
     }
     if ($request->has('count') && $request->has('page')) {
         $results = $results->skip($count * ($page - 1))->take($count);
     }
     $results = $results->get();
     $filter_yetkiler = Role::select('id', 'display_name as title')->get();
     return array('results' => $results, 'inlineCount' => User::count(), 'yetkiler' => $yetkiler, 'filter_yetkiler' => $filter_yetkiler);
 }
Example #9
Show file File: Forgot_pass.php Project: samoldenburg/Stepmania-Leaderboards
0
 public function reset_pass($token = null)
 {
     if (empty($token)) {
         redirect('forgot_pass');
     } else {
         if (User::count(array('conditions' => array('pass_key = ?', $token))) == 0) {
             redirect('forgot_pass');
         }
     }
     $this->data['token'] = $token;
     $this->data['user'] = User::find_by_pass_key($token);
     if ($_POST) {
         if ($this->form_validation->run('pass_reset') == FALSE) {
             $this->content_view = 'forgot_pass/reset_pass';
             $this->data['error'] = true;
         } else {
             $this->data['user']->password = crypt($this->input->post('pass') . $this->data['user']->salt);
             $this->data['user']->pass_key = "";
             $this->data['user']->save();
             $this->content_view = 'forgot_pass/reset_pass_confirm';
         }
     } else {
         $this->content_view = "forgot_pass/reset_pass";
     }
 }
Example #10
Show file File: AdminUsersControllerTest.php Project: riehlemt/neontsunami
0
 public function testDestroy()
 {
     $user = Factory::create('User');
     $this->action('DELETE', 'Admin\\UsersController@destroy', $user->id);
     $this->assertRedirectedToRoute('admin.users.index');
     $this->assertEquals(0, User::count());
 }
Example #11
Show file File: UsersController.php Project: aspotato/LinkDB
0
 public function index()
 {
     $total = User::count();
     $users = User::orderby('id')->paginate(10);
     $this->layout->title = "Users";
     $this->layout->content = View::make('users.index', compact('users', 'total'));
 }
Example #12
Show file File: IndexController.php Project: stylenic/phalcon
0
 public function indexAction()
 {
     header("Content-type: text/html; charset=utf-8");
     //查询条件
     $condition = '';
     $data_count = User::count($condition);
     $page_num = 5;
     $current_page = (int) $_GET["page"];
     //分页处理
     $pagination = Tools::pagination($data_count, $page_num, $current_page);
     //分页条件
     $limit = array("limit" => array("number" => $page_num, "offset" => $pagination->offset));
     //获取数据
     $list = User::find($limit);
     //结果展示
     foreach ($list as $item) {
         echo $item->id . ':' . $item->name . '<br/>';
     }
     //数字分页展示
     for ($i = 1; $i <= $pagination->maxPage; $i++) {
         echo "<a href='?page={$i}'>{$i}</a> ";
     }
     //翻页展示
     echo "<a href='?page=1'>首页</a> ";
     echo "<a href='?page={$pagination->prePage}'>上一页</a> ";
     echo "<a href='?page={$pagination->nextPage}'>下一页</a> ";
     echo "<a href='?page={$pagination->maxPage}'>尾页</a> ";
     //TODO 当前页为首页或尾页时A标签的状态处理
     die;
 }
Example #13
Show file File: Group.php Project: Max201/nanocore
0
 public function to_array()
 {
     $array = parent::to_array();
     $array['use_admin'] = $this->can('use_admin');
     $array['users'] = User::count(['conditions' => ['group_id = ?', $this->id]]);
     return $array;
 }
Example #14
Show file File: AdminController.php Project: soberanes/dalecms
0
 public function index()
 {
     $contacts_count = Contact::count();
     $users_count = User::count();
     $data = array("contacts_count" => $contacts_count, "contacts_count" => $contacts_count);
     return View::make('admin.index', $data);
 }
Example #15
Show file File: HomeController.php Project: sonico999/Multitenant-Apps-in-Laravel
0
 public function dashboard()
 {
     $counts = ['organizations' => Organization::count(), 'users' => User::count(), 'todos' => Todo::count(), 'mt_users' => User::has('organizations', '>', 1)->count()];
     $newestOrg = Organization::orderBy('created_at', 'desc')->first();
     $orgWithMostTodos = DB::table('organizations')->select(['organizations.name', DB::raw('count(todos.organization_id) as total')])->join('todos', 'todos.organization_id', '=', 'organizations.id')->orderBy('total', 'desc')->groupBy('todos.organization_id')->first();
     $this->view('dashboard', compact('counts', 'newestOrg', 'orgWithMostTodos'));
 }
Example #16
Show file File: LoginControllerTest.php Project: scottdavis/pearfarm_channel_server
0
 public function testCreateFails()
 {
     $c = User::count();
     $this->post('create', array(), array('whoanow' => '', 'v_password' => 'password', 'user' => array('username' => 'poopy', 'email' => '', 'password' => 'password')));
     $this->assertEquals($c, User::count(array('cache' => false)));
     $this->assertTemplate('add');
 }
Example #17
Show file File: login_form.php Project: epochwolf/kairos
0
 private function create_inital_user()
 {
     if (User::count() == 0) {
         $user = new User(["username" => "admin", "password" => "admin", "admin" => true]);
         $user->save();
     }
 }
Example #18
Show file File: admin.php Project: nytr0gen/plur-music-explorer
0
 private function admin()
 {
     $today = strtotime('today');
     $month = strtotime('first day of this month');
     $last30 = strtotime('-30 days');
     // Users statistics
     $users['today'] = number_format(User::whereGt('reg_date', $today)->count());
     $users['month'] = number_format(User::whereGt('reg_date', $month)->count());
     $users['last30'] = number_format(User::whereGt('reg_date', $last30)->count());
     $users['total'] = number_format(User::count());
     View::set('users', $users);
     // Playlists statistics
     $playlists['today'] = number_format(Playlist::whereGt('date', $today)->count());
     $playlists['month'] = number_format(Playlist::whereGt('date', $month)->count());
     $playlists['last30'] = number_format(Playlist::whereGt('date', $last30)->count());
     $playlists['total'] = number_format(Playlist::count());
     View::set('playlists', $playlists);
     // Tracks statistics
     $tracks = number_format(Track::count());
     View::set('tracks', $tracks);
     // Tags statistics
     $tags = number_format(Tag::count());
     View::set('tags', $tags);
     // Comments statistics
     $comments = number_format(Comment::count());
     View::set('comments', $comments);
     // Likes
     $likes = number_format(PlaylistLike::count());
     View::set('likes', $likes);
     // Reports
     $reports = number_format(Report::count());
     View::set('reports', $reports);
     View::show('admin/admin');
 }
Example #19
Show file File: AppController.php Project: neilmillard/kanbanlist
0
 public function index()
 {
     Log::info(get_class(App::make('view.finder')));
     $all_user_count = User::count();
     $today_task_count = Task::todayCount();
     $all_task_count = Task::count();
     return View::make('app.index', compact('all_user_count', 'today_task_count', 'all_task_count'));
 }
Example #20
Show file File: DatabaseSeeder.php Project: blestab/laravel-school-erp
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     // $this->call('UserTableSeeder');
     //Create Default Admin User
     if (User::count() == 0) {
         User::create(array('first_name' => 'Fakhar', 'last_name' => 'Khan', 'email' => 'fakhar@softpyramid.com', 'password' => '123456'));
     }
 }
Example #21
Show file File: DatabaseSeeder.php Project: fakharkhan/laravel-bootstrap
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     // $this->call('UserTableSeeder');
     //Create Default Admin User
     if (User::count() == 0) {
         User::create(array('fullname' => 'Administrator', 'email' => 'admin@example.com', 'password' => '123456'));
     }
 }
Example #22
Show file File: admin.php Project: shreyanshgoel/tours
0
 /**
  * @before _secure, changeLayout
  */
 public function index()
 {
     $this->seo(array("title" => "Dashboard", "view" => $this->getLayoutView()));
     $view = $this->getActionView();
     $users = \User::count();
     $data = array("users" => $users);
     $data = ArrayMethods::toObject($data);
     $view->set("data", $data);
 }
Example #23
Show file File: Ajax.php Project: samoldenburg/Stepmania-Leaderboards
0
 public function displayname_exists($username = null)
 {
     if (!empty($username)) {
         $this->content_view = 'ajax/username_exists';
         $this->data['exists'] = User::count(array('conditions' => array('display_name = ?', $username)));
     } else {
         $this->data['exists'] = 2;
     }
 }
Example #24
Show file File: IpxController.php Project: Vrian7ipx/repocas
0
 public function dashboard()
 {
     $sucursales = Branch::count();
     $usuarios = User::count();
     $clientes = Client::count();
     $productos = Product::count();
     $informacionCuenta = array('sucursales' => $sucursales, 'usuarios' => $usuarios, 'clientes' => $clientes, 'productos' => $productos);
     // return Response::json($informacionCuenta);
     return View::make('cuentas.dashboard')->with('cuenta', $informacionCuenta);
 }
Example #25
Show file File: ModelTest.php Project: gigorok/php-orm
0
 public function testModel()
 {
     $this->assertEquals(User::find(1)->email, 'email1@example.com');
     $this->assertEquals(User::first()->email, 'email1@example.com');
     $this->assertEquals(User::last()->email, 'email3@example.com');
     $this->assertEquals(User::count(), 3);
     $this->assertEquals(User::findOne(['email'], ['email1@example.com'])->email, 'email1@example.com');
     $this->assertEquals(User::findOne(['first_name', 'last_name'], ['John', 'Doe'])->email, 'email1@example.com');
     $this->assertCount(3, User::all());
 }
Example #26
Show file File: AdminController.php Project: carriercomm/sticky-notes
0
 /**
  * Displays the administration dashboard
  *
  * @access public
  * @return \Illuminate\Support\Facades\View
  */
 public function getDashboard()
 {
     // Get all stats for the last 1 month
     $duration = Site::config('general')->statsDisplay;
     $date = date('Y-m-d', strtotime($duration));
     $stats = Statistics::where('date', '>', $date)->orderBy('date')->get()->toArray();
     // Build the view data
     $data = array('users' => User::count(), 'pastes' => Paste::count(), 'php_version' => phpversion(), 'sn_version' => Config::get('app.version'), 'db_driver' => Config::get('database.default'), 'stats' => $stats);
     return View::make('admin/dashboard', $data);
 }
Example #27
Show file File: member.php Project: SwiftDeal/detectr
0
 /**
  * @before _secure, _admin
  */
 public function all()
 {
     $this->seo(array("title" => "View Users Stats", "keywords" => "admin", "description" => "admin", "view" => $this->getLayoutView()));
     $view = $this->getActionView();
     $page = RequestMethods::get("page", 1);
     $limit = RequestMethods::get("limit", 10);
     $orderBy = RequestMethods::get("orderBy", "created");
     $users = \User::all(array(), array("*"), $orderBy, "desc", $limit, $page);
     $total = \User::count();
     $view->set(array("count" => $total, "results" => $users, "limit" => $limit, "page" => (int) $page));
 }
Example #28
Show file File: PaginationTest.php Project: scottdavis/nimblize
0
 /**
  * @dataProvider PaginationData
  */
 public function testPaginationReturns($page, $per_page, $total, $ids)
 {
     $users = User::paginate(array('per_page' => $per_page, 'page' => $page));
     $this->assertEquals($total, count($users));
     $this->assertEquals(collect(function ($u) {
         return $u->id;
     }, $users), $ids);
     $this->assertEquals(User::count(), $users->total_count);
     $this->assertEquals($per_page, $users->per_page);
     $this->assertEquals($page, $users->page);
 }
Example #29
Show file File: PoliceController.php Project: saifurrahman/dev
0
 public function getDashdetails()
 {
     $guestlist_date = date('Y-m-d', strtotime(date('Y-m-d') . "-1 days"));
     $registered = User::count();
     $subimitted = Hotelrecord::select(DB::raw('count(*) as subimitted_hotels'))->where('guestlist_date', $guestlist_date)->get();
     $totals = Hotelrecord::select(DB::raw('sum(total_check_in) as total_check_in, sum(total_check_out) as total_check_out, sum(foreign_guest) as foreign_guest'))->where('guestlist_date', $guestlist_date)->get();
     $totals[0]['guestlist_date'] = date("d-M-Y", strtotime($guestlist_date));
     $totals[0]['subimitted_hotels'] = $subimitted[0]['subimitted_hotels'];
     $totals[0]['registered'] = $registered - 5;
     return Response::json($totals);
 }
Example #30
Show file File: UserLimitPlugin.php Project: himmelex/NTW
0
 function _checkMaxUsers()
 {
     if (!is_null($this->maxUsers)) {
         $cls = new User();
         $cnt = $cls->count();
         if ($cnt >= $this->maxUsers) {
             $msg = sprintf(_('Cannot register; maximum number of users (%d) reached.'), $this->maxUsers);
             throw new ClientException($msg);
         }
     }
 }