/** * 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')); }
/** * 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]); }
/** * 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; }
/** * 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()); }
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')); }
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); }
/** * 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')); }
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(); }