src/Controller/DashboardController.php line 26

  1. <?php
  2. namespace App\Controller;
  3. use App\Repository\AcademicYearRepository;
  4. use App\Repository\AdminsRepository;
  5. use App\Repository\LecturerCourseRepository;
  6. use App\Repository\LecturersRepository;
  7. use App\Repository\PaymentsRepository;
  8. use App\Repository\SchoolRepository;
  9. use App\Repository\StudentsRepository;
  10. use App\Repository\WalletRepository;
  11. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  12. use Symfony\Component\HttpFoundation\Response;
  13. use Symfony\Component\Routing\Annotation\Route;
  14. class DashboardController extends AbstractController
  15. {
  16.     public function __construct(private AdminsRepository $adminsRepository, private SchoolRepository $schoolRepository, private PaymentsRepository $paymentsRepository, private StudentsRepository $studentsRepository, private AcademicYearRepository $academicYearRepository, private LecturersRepository $lecturersRepository, private LecturerCourseRepository $lecturerCourseRepository, private WalletRepository $walletRepository)
  17.     {
  18.     }
  19.     #[Route('/'name'app_firstpage')]
  20.     #[Route('/dashboard'name'app_dashboard')]
  21.     public function index(): Response
  22.     {
  23.         $currentuser $this->getUser();
  24.         if (empty($this->schoolRepository->findBy(['deleted' => false], [], 1))) {
  25.             $this->addFlash('error''Please enter school info before proceeding !');
  26.             return $this->redirectToRoute('app_school_index');
  27.         }
  28.         $academicYear $this->academicYearRepository->findOneBy([
  29.             'status' => true
  30.         ]);
  31.         if ($this->isGranted('ROLE_SUPER_ADMIN')) {
  32.             $newStudent $this->studentsRepository->getStudents(50);
  33.         } else {
  34.             $newStudent $this->studentsRepository->getStudents(50true);
  35.         }
  36. //        dd($newStudent->getQuery()->getResult());
  37.         $wallet $this->walletRepository->userBalance($currentuser->getPerson());
  38.         return $this->render('dashboard/index.html.twig', [
  39.             'payment_data' => json_encode($this->paymentsRepository->getTotalAmountPerMonth()),
  40.             'adminDebt' => $this->adminsRepository->totalDebt(),
  41.             'studentsDebt' => $this->studentsRepository->totalDebt(),
  42.             'lecturerDebt' => $this->lecturersRepository->totalDebt(),
  43.             'academicYear' => $academicYear,
  44.             'wallet' => $wallet,
  45.             'payments' => $this->paymentsRepository->findBy(['deleted' => false], ['id' => 'DESC'], 7),
  46.             'totalstudent' => $this->studentsRepository->countAllStudents(),
  47.             'new_student' => $newStudent->getQuery()->getResult(),
  48.             'new_student_count' => $this->studentsRepository->countNewStudents(),
  49.         ]);
  50.     }
  51. //    #[Route('/verification', name: 'app_verificatation')]
  52. //    public function verification(): Response
  53. //    {
  54. //        dd($this->isGranted('ROLE_STUDENT'));
  55. //        if ($this->isGranted('ROLE_LECTURER') || $this->isGranted('ROLE_STUDENT') || $this->isGranted('ROLE_AGENT')) {
  56. //            $this->addFlash('error', 'Permission denied !');
  57. //            return $this->redirectToRoute('app_logout');
  58. //        }
  59. //        return $this->redirectToRoute('app_dashboard');
  60. //    }
  61. }