src/Controller/IndexController.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\Routing\Annotation\Route;
  5. class IndexController extends AbstractController {
  6.     #[Route(path'/'name'app_index')]
  7.     public function index() {
  8.         $user $this->getUser();
  9.         if (in_array("ROLE_ADMIN"$user->getRoles())) {
  10.             return $this->redirectToRoute('api_user_index');
  11.         } elseif (in_array("ROLE_VETERINARY"$user->getRoles())) {
  12.             return $this->redirectToRoute('api_client_index');
  13.         }else{
  14.             return $this->redirectToRoute('app_login');
  15.         }
  16.     }
  17. }