3 namespace BookStack\Http\Controllers;
6 use BookStack\Repos\EntityRepo;
7 use BookStack\Http\Requests;
10 class HomeController extends Controller
12 protected $entityRepo;
15 * HomeController constructor.
16 * @param EntityRepo $entityRepo
18 public function __construct(EntityRepo $entityRepo)
20 $this->entityRepo = $entityRepo;
21 parent::__construct();
26 * Display the homepage.
29 public function index()
31 $activity = Activity::latest(10);
32 $draftPages = $this->signedIn ? $this->entityRepo->getUserDraftPages(6) : [];
33 $recentFactor = count($draftPages) > 0 ? 0.5 : 1;
34 $recents = $this->signedIn ? Views::getUserRecentlyViewed(12*$recentFactor, 0) : $this->entityRepo->getRecentlyCreatedBooks(10*$recentFactor);
35 $recentlyCreatedPages = $this->entityRepo->getRecentlyCreatedPages(5);
36 $recentlyUpdatedPages = $this->entityRepo->getRecentlyUpdatedPages(5);
38 'activity' => $activity,
39 'recents' => $recents,
40 'recentlyCreatedPages' => $recentlyCreatedPages,
41 'recentlyUpdatedPages' => $recentlyUpdatedPages,
42 'draftPages' => $draftPages