当前位置: 首页>>代码示例>>PHP>>正文


PHP User::limit方法代码示例

本文整理汇总了PHP中App\Model\User::limit方法的典型用法代码示例。如果您正苦于以下问题:PHP User::limit方法的具体用法?PHP User::limit怎么用?PHP User::limit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在App\Model\User的用法示例。


在下文中一共展示了User::limit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 public function index()
 {
     //总访问量
     $visits = \Cache::get('visits', 0);
     //今日注册用户
     $todayUsers = User::today()->count('user_id');
     //总用户数
     $totalUsers = User::count('user_id');
     //管理员聊天记录
     $chatMessages = AdminMessage::with('admin')->limit(10)->oldest()->get();
     //最新留言
     $guestBook = GuestBook::with('user')->limit(10)->oldest()->get();
     //最新注册用户
     $users = User::limit(24)->oldest()->get();
     //最新评论
     $comments = Comment::limit(10)->oldest()->get();
     // 总会员数量/待审核会员/普通会员/高端会员
     $user_all_num = User::count('user_id');
     $user_shenhe_num = User::status(\App\Enum\User::STATUS_CHECK)->count('user_id');
     $user_level1_num = User::level(\App\Enum\User::LEVEL_1)->count('user_id');
     $user_level3_num = User::level(\App\Enum\User::LEVEL_3)->count('user_id');
     // 自我介绍待审核数量
     $user_info_num = UserInfo::where('introduce_status', \App\Enum\User::INTRODUCE_CHECK)->count('user_id');
     // 会员相片审核数量
     $user_gallery_num = DB::table('user_gallery')->where('status', '待审核')->where('image_url', '!=', '')->count('photo_id');
     // 文章数量
     $article_num = DB::table('articles')->count('article_id');
     $res = array('user_all_num' => $user_all_num, 'user_shenhe_num' => $user_shenhe_num, 'user_level1_num' => $user_level1_num, 'user_level3_num' => $user_level3_num, 'user_info_num' => $user_info_num, 'user_gallery_num' => $user_gallery_num, 'article_num' => $article_num);
     return $this->view('index', $res);
     // return $this->view('index')->with('visits', $visits)->with('todayUsers', $todayUsers)->with('totalUsers',
     //         $totalUsers)->with('chatMessages', $chatMessages)->with('guestBook', $guestBook)->with('users',
     //         $users)->with('comments', $comments);
 }
开发者ID:netxinyi,项目名称:meigui,代码行数:33,代码来源:HomeController.php

示例2: testLimit

 public function testLimit()
 {
     /*
     		$conn->query("DELETE FROM users");
     		$conn->query("INSERT INTO users(id,name) VALUES(1,'bar'), (2, 'foo'), (3, 'hoge'), (4, 'fuga')");
     		
     		$conn->query("DELETE FROM comments");
     		$conn->query("INSERT INTO comments(id, text, user_id)
     			VALUES(1, 'bar comment first', 1), (2, 'bar comment second', 1), (3, 'foo comment first', 2)");
     
     		$conn->query("DELETE FROM users_skills");
     		$conn->query("INSERT INTO users_skills(id, users_id, skills_id) 
     			VALUES(1, 1, 1), (2, 1, 2), (3, 2, 1)");
     	
     		$conn->query("DELETE FROM skills");
     		$conn->query("INSERT INTO skills(id, name)
     			 VALUES(1,'skill1'), (2, 'skill2'), (3, 'skill3')");
     
     		$conn->query("DELETE FROM profiles");
     		$conn->query("INSERT INTO profiles(id, text, user_id) 
     			VALUES(1, 'bar profile', 1), (2, 'foo frofile', 2), (3, 'hoge frofile', 3)");
     */
     $users = User::limit(4);
     $this->assertEquals('bar profile', $users[0]->Profile->text);
     $this->assertEquals('foo frofile', $users[1]->Profile->text);
     $this->assertEquals('hoge frofile', $users[2]->Profile->text);
     $this->assertEquals(null, $users[3]->Profile);
     $this->assertEquals('bar comment first', $users[0]->Comment[0]->text);
     $this->assertEquals('bar comment second', $users[0]->Comment[1]->text);
     $this->assertEquals('foo comment first', $users[1]->Comment[0]->text);
     $this->assertEquals([], $users[2]->Comment);
     $this->assertEquals([], $users[3]->Comment);
     $this->assertEquals('skill1', $users[0]->Skill[0]->name);
     $this->assertEquals('skill1', $users[1]->Skill[0]->name);
     $this->assertEquals([], $users[2]->Skill);
     $this->assertEquals([], $users[3]->Skill);
 }
开发者ID:turuwo3,项目名称:activerecord,代码行数:37,代码来源:RecordAssociationTest.php


注:本文中的App\Model\User::limit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。