Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

41 řádky
1.1KB

  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Controllers;
  4. use App\Repositories\CampaignRepository;
  5. use App\Repositories\CampaignTypeRepository;
  6. use App\Repositories\JobRepository;
  7. use App\Repositories\JobTypeRepository;
  8. use App\ViewModels\HomeIndexViewModel;
  9. use Core\Controller;
  10. class HomeController extends Controller
  11. {
  12. public function index()
  13. {
  14. $db = database();
  15. $model = new HomeIndexViewModel();
  16. $model->totalCampaignTypes = (new CampaignTypeRepository($db))->count();
  17. $model->totalCampaigns = (new CampaignRepository($db))->count();
  18. $model->totalJobTypes = (new JobTypeRepository($db))->count();
  19. $model->totalJobs = (new JobRepository($db))->count();
  20. $model->recentCampaigns = (new CampaignRepository($db))->recentWithType(5);
  21. $model->campaignsByType = (new CampaignRepository($db))->countByType();
  22. return $this->view('home.index', [
  23. 'model' => $model,
  24. 'pageTitle' => 'Dashboard',
  25. ]);
  26. }
  27. public function user(string $id)
  28. {
  29. return $this->json([
  30. 'userId' => $id,
  31. ]);
  32. }
  33. }

Powered by TurnKey Linux.