src/Controller/DashboardController.php line 26
<?phpnamespace App\Controller;use App\Repository\AcademicYearRepository;use App\Repository\AdminsRepository;use App\Repository\LecturerCourseRepository;use App\Repository\LecturersRepository;use App\Repository\PaymentsRepository;use App\Repository\SchoolRepository;use App\Repository\StudentsRepository;use App\Repository\WalletRepository;use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;use Symfony\Component\HttpFoundation\Response;use Symfony\Component\Routing\Annotation\Route;class DashboardController extends AbstractController{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){}#[Route('/', name: 'app_firstpage')]#[Route('/dashboard', name: 'app_dashboard')]public function index(): Response{$currentuser = $this->getUser();if (empty($this->schoolRepository->findBy(['deleted' => false], [], 1))) {$this->addFlash('error', 'Please enter school info before proceeding !');return $this->redirectToRoute('app_school_index');}$academicYear = $this->academicYearRepository->findOneBy(['status' => true]);if ($this->isGranted('ROLE_SUPER_ADMIN')) {$newStudent = $this->studentsRepository->getStudents(50);} else {$newStudent = $this->studentsRepository->getStudents(50, true);}// dd($newStudent->getQuery()->getResult());$wallet = $this->walletRepository->userBalance($currentuser->getPerson());return $this->render('dashboard/index.html.twig', ['payment_data' => json_encode($this->paymentsRepository->getTotalAmountPerMonth()),'adminDebt' => $this->adminsRepository->totalDebt(),'studentsDebt' => $this->studentsRepository->totalDebt(),'lecturerDebt' => $this->lecturersRepository->totalDebt(),'academicYear' => $academicYear,'wallet' => $wallet,'payments' => $this->paymentsRepository->findBy(['deleted' => false], ['id' => 'DESC'], 7),'totalstudent' => $this->studentsRepository->countAllStudents(),'new_student' => $newStudent->getQuery()->getResult(),'new_student_count' => $this->studentsRepository->countNewStudents(),]);}// #[Route('/verification', name: 'app_verificatation')]// public function verification(): Response// {// dd($this->isGranted('ROLE_STUDENT'));// if ($this->isGranted('ROLE_LECTURER') || $this->isGranted('ROLE_STUDENT') || $this->isGranted('ROLE_AGENT')) {// $this->addFlash('error', 'Permission denied !');// return $this->redirectToRoute('app_logout');// }// return $this->redirectToRoute('app_dashboard');// }}