src/Controller/Gestion/DashboardController.php line 21
<?phpnamespace App\Controller\Gestion;use App\Form\SearchType;use App\Repository\Finder\SearchFinder;use App\Repository\OrderRepository;use App\Repository\ShopRepository;use Knp\Component\Pager\PaginatorInterface;use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;use Symfony\Component\Form\Extension\Core\Type\CheckboxType;use Symfony\Component\Form\Extension\Core\Type\ChoiceType;use Symfony\Component\HttpFoundation\Request;use Symfony\Component\HttpFoundation\Response;use Symfony\Component\Routing\Annotation\Route;#[Route('/gestion')]class DashboardController extends AbstractController{#[Route('/', name: 'app_gestion_dashboard_index')]public function index(OrderRepository $repository,PaginatorInterface $paginator,Request $request,ShopRepository $shopRepository,): Response {$query = $repository->findDefault();$form = $this->createForm(SearchType::class, ['q' => $request->get('q'),'shop' => $request->get('shop'),'archived' => (bool)$request->get('archived'),])->add('shop', ChoiceType::class, ['choices' => $shopRepository->findList(),'label'=> false,'placeholder' => 'Filtrer par boutique',])->add('archived', CheckboxType::class, ['false_values' => [null, 0],'required' => false,'label' => 'Commandes archivées']);if ($request->get('q')) {$query = SearchFinder::findLike($query,$request->get('q'),$repository::SEARCH_FIELDS);}if (!$request->get('archived')) {$query->andWhere('o.ended = 0');}if ($shopId = $request->get('shop')) {$query->andWhere('o.shop = :shop')->setParameter('shop', $shopId);}$pagination = $paginator->paginate($query,$request->query->getInt('page', 1),$request->query->getInt('limit', 20),[PaginatorInterface::DEFAULT_SORT_FIELD_NAME => 'o.dateUpdate',PaginatorInterface::DEFAULT_SORT_DIRECTION => 'DESC',PaginatorInterface::PAGE_OUT_OF_RANGE => PaginatorInterface::PAGE_OUT_OF_RANGE_FIX]);return $this->render('gestion/dashboard/index.html.twig', ['pagination' => $pagination,'search_form' => $form->createView(),]);}}