50 lines
1.5 KiB
PHP
50 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Controller\Teamer\Disposition;
|
|
|
|
use App\Entity\User;
|
|
use App\Repository\DispositionRepository;
|
|
use Knp\Component\Pager\PaginatorInterface;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Symfony\Component\Routing\Annotation\Route;
|
|
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
|
|
|
class RecentController extends AbstractController
|
|
{
|
|
public function __construct(
|
|
private readonly DispositionRepository $dispositionRepository,
|
|
private readonly PaginatorInterface $paginator
|
|
) {
|
|
}
|
|
|
|
#[Route('/teamer/disposition/recent', name: 'app_teamer_disposition_recent')]
|
|
#[IsGranted('ROLE_TEAMER')]
|
|
public function index(Request $request): Response
|
|
{
|
|
/** @var User $user */
|
|
$user = $this->getUser();
|
|
$teamer = $user->getTeamer();
|
|
|
|
$query = $this
|
|
->dispositionRepository
|
|
->getRecentQuery($teamer)
|
|
;
|
|
|
|
$pagination = $this->paginator->paginate(
|
|
$query,
|
|
$request->query->getInt('page', 1),
|
|
10,
|
|
[
|
|
'defaultSortFieldName' => 'assignment.dateFrom',
|
|
'defaultSortDirection' => 'asc',
|
|
]
|
|
);
|
|
|
|
return $this->render('teamer/disposition/recent.html.twig', [
|
|
'teamer' => $teamer,
|
|
'pagination' => $pagination,
|
|
]);
|
|
}
|
|
} |