예제 #1
0
 public function index()
 {
     $blogs = Blog::with('user')->orderBy('created_at', 'desc')->paginate(15);
     $downloads = Download::with('user')->orderBy('created_at', 'desc')->paginate(15);
     $samples = Sample::with('user')->orderBy('created_at', 'desc')->paginate(15);
     $lastusers = User::orderBy('created_at', 'desc')->paginate(15);
     $sample_cats = Samplecategories::all();
     $guests = Online::guests()->count();
     return view('index', compact('blogs', 'downloads', 'samples', 'sample_cats', 'lastusers', 'guests'));
 }
예제 #2
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     // CREATE $allBlogs WITH ASSOCIATED TAGLINES AND USERS
     $allBlogs = Blog::with('user')->orderBy('id', 'desc')->get();
     return view('blog.index', compact('allBlogs'));
 }
예제 #3
0
 public function statistics()
 {
     $frequentTags = Tag::with('articles')->get()->take(10)->map(function ($t) {
         return ['label' => $t->name, 'data' => $t->articles()->get()->count()];
     });
     $activeBloggers = Blog::with('articles')->get()->take(10)->map(function ($b) {
         return ['username' => $b->username, 'articlesCount' => $b->articles()->get()->count()];
     });
     $mostVisitedBlogs = Blog::with('user')->get()->take(10)->map(function ($b) {
         return ['label' => $b->user['firstName'] . ' ' . $b->user['firstName'] . ' (' . $b->username . ')', 'data' => $b->views];
     });
     $disabledBlogsCount = Blog::with('user')->where('status', 'inactive')->count();
     return ['frequentTags' => $frequentTags, 'activeBloggers' => $activeBloggers, 'mostVisitedBlogs' => $mostVisitedBlogs, 'disabledBlogsCount' => $disabledBlogsCount, 'studentsCount' => User::where('role', '=', 'eleve')->get()->count(), 'teachersCount' => User::where('role', '=', 'prof')->get()->count(), 'articlesCount' => Article::all()->count()];
 }