コード例 #1
0
 /**
  * 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'));
 }
コード例 #2
0
 /**
  * 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]);
 }
コード例 #3
0
ファイル: BoardStats.php プロジェクト: nitogel/infinity-next
 /**
  * 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;
 }
コード例 #4
0
 /**
  * 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());
 }
コード例 #5
0
ファイル: HomeController.php プロジェクト: majid-n/cometdev
 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'));
 }
コード例 #6
0
ファイル: AdminController.php プロジェクト: Gadurp1/KD-2
 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);
 }
コード例 #7
0
ファイル: StatsController.php プロジェクト: celine24/Back
 /**
  * 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'));
 }
コード例 #8
0
ファイル: ModelTest.php プロジェクト: idealogica/lavanda
 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();
 }