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


PHP Post::count方法代码示例

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


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

示例1: index

 /**
  * Display the dashboard once the user is logged
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $nb_users = User::count();
     $nb_posts = Post::count();
     $nb_pages = Page::count();
     return view('admin.admin', compact('nb_users', 'nb_posts', 'nb_pages'));
 }
开发者ID:victorboissiere,项目名称:Synergie,代码行数:12,代码来源:DashboardController.php

示例2: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $users_count = User::count();
     $posts_count = Post::count();
     $galleries_count = Gallery::count();
     return response()->json(['users_count' => $users_count, 'posts_count' => $posts_count, 'galleries_count' => $galleries_count]);
 }
开发者ID:szwork2013,项目名称:laravel-angular-cms,代码行数:12,代码来源:DashboardController.php

示例3: boardStats

 /**
  * Returns the information specified by boardStats
  *
  * @return array (indexes and vales based on $boardStats)
  */
 protected function boardStats()
 {
     $controller =& $this;
     $stats = Cache::remember('index.boardstats', 60, function () use($controller) {
         $stats = [];
         foreach ($controller->boardStats as $boardStat) {
             switch ($boardStat) {
                 case "boardCount":
                     $stats[$boardStat] = Board::whereIndexed()->count();
                     break;
                 case "boardIndexedCount":
                     $stats[$boardStat] = Board::count();
                     break;
                 case "postCount":
                     $stats[$boardStat] = Post::count();
                     break;
                 case "postRecentCount":
                     $stats[$boardStat] = Post::recent()->count();
                     break;
             }
         }
         return $stats;
     });
     return $stats;
 }
开发者ID:nitogel,项目名称:infinity-next,代码行数:30,代码来源:BoardStats.php

示例4: testNumberOfPostsIsEqualOrHigherAfterUpdate

 /**
  * Assert that the numbers of posts doens't decline after running update command
  *
  * @return void
  */
 public function testNumberOfPostsIsEqualOrHigherAfterUpdate()
 {
     $totalPosts = Post::count();
     $totalDificultyLevels = PostDificulty::count();
     Artisan::call('update', ['--migrationRefresh' => 'default']);
     $this->assertTrue($totalDificultyLevels <= PostDificulty::count());
     $this->assertTrue($totalPosts <= Post::count());
 }
开发者ID:joaumg-deprecated,项目名称:joaumg_com,代码行数:13,代码来源:CommandUpdateTest.php

示例5: index

 public function index()
 {
     $totallikes = Like::count();
     $totalposts = Post::count();
     $posts = Post::with('cat', 'likes')->paginate(config('app.posts_per_page'));
     $page = $posts->currentPage();
     $lastpage = $posts->lastPage();
     return view('index', compact('totallikes', 'totalposts', 'posts', 'page', 'lastpage', 'title'));
 }
开发者ID:majid-n,项目名称:cometdev,代码行数:9,代码来源:HomeController.php

示例6: index

 public function index()
 {
     $pages = \App\Page::count();
     $banners = \App\Banner::count();
     $coupons = \App\Coupons::count();
     $posts = \App\Post::count();
     $users = \App\User::count();
     $images = \App\Image::count();
     return view('home')->with('pages', $pages)->with('banners', $banners)->with('coupons', $coupons)->with('posts', $posts)->with('users', $users)->with('images', $images);
 }
开发者ID:Gadurp1,项目名称:KD-2,代码行数:10,代码来源:AdminController.php

示例7: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $posts_published = Post::published()->count();
     $posts_editing = Post::where('published', 'uc')->count();
     $posts_sticky = Post::where('is_sticky', 'on')->count();
     $posts = Post::count();
     $users = User::count();
     $jobs = Job::count();
     $questions = Question::count();
     $categories = Category::count();
     return view('admin.stats.index', compact('posts', 'posts_published', 'posts_sticky', 'posts_editing', 'users', 'jobs', 'questions', 'categories'));
 }
开发者ID:celine24,项目名称:Back,代码行数:17,代码来源:StatsController.php

示例8: testSaveWithRelations

 public function testSaveWithRelations()
 {
     // one-to-many, many-to-many
     $item = factory(App\Post::class)->make();
     $post = $item->toArray();
     $post['comments'] = [];
     $post['comments'][] = factory(App\Comment::class)->make()->toArray();
     $post['tags'] = [];
     foreach (App\Tag::all() as $t) {
         $post['tags'][] = $t['id'];
     }
     $item->saveWithRelations($post);
     $item = App\Post::find(4);
     self::assertInstanceOf('App\\Post', $item);
     self::assertEquals('4', $item['id']);
     $tags = $item->tags;
     self::assertCount(3, $tags);
     $comments = $item->comments;
     self::assertCount(1, $comments);
     // one-to-one
     $item = factory(App\Comment::class)->make();
     $comment = $item->toArray();
     $comment['post'] = factory(App\Post::class)->make()->toArray();
     $item->saveWithRelations($comment);
     $item = App\Comment::find(11);
     self::assertEquals('11', $item['id']);
     self::assertEquals(11, App\Comment::count());
     $post = $item->post;
     self::assertEquals('5', $post['id']);
     self::assertEquals(5, App\Post::count());
     // db rollback
     $this->rollback();
 }
开发者ID:idealogica,项目名称:lavanda,代码行数:33,代码来源:ModelTest.php


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