Browse Source

Change l'ordre de tri des projets

master
vincent 2 weeks ago
parent
commit
cdaa1bb886
2 changed files with 13 additions and 15 deletions
  1. +1
    -1
      src/Controller/ProjectController.php
  2. +12
    -14
      src/Repository/ProjectRepository.php

+ 1
- 1
src/Controller/ProjectController.php View File

@ -22,7 +22,7 @@ class ProjectController extends AbstractController
#[Route('/', name: 'app_project')] #[Route('/', name: 'app_project')]
public function index(EntityManagerInterface $entityManager): Response public function index(EntityManagerInterface $entityManager): Response
{ {
$projects = $entityManager->getRepository(Project::class)->findAll();
$projects = $entityManager->getRepository(Project::class)->findAllOrderedByActivity();
return $this->render('project/index.html.twig', [ return $this->render('project/index.html.twig', [
'projects' => $projects, 'projects' => $projects,


+ 12
- 14
src/Repository/ProjectRepository.php View File

@ -3,6 +3,7 @@
namespace App\Repository; namespace App\Repository;
use App\Entity\Project; use App\Entity\Project;
use App\Entity\Task;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ManagerRegistry;
@ -16,20 +17,17 @@ class ProjectRepository extends ServiceEntityRepository
parent::__construct($registry, Project::class); parent::__construct($registry, Project::class);
} }
// /**
// * @return Project[] Returns an array of Project objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('p')
// ->andWhere('p.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('p.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
/**
* @return Project[] Returns an array of Project objects
*/
public function findAllOrderedByActivity(): array
{
return $this->createQueryBuilder('p')
->orderBy('p.createdAt', 'DESC')
->getQuery()
->getResult()
;
}
// public function findOneBySomeField($value): ?Project // public function findOneBySomeField($value): ?Project
// { // {


Loading…
Cancel
Save