<?php

namespace App\Repository\Properties;

use App\Entity\Properties\Categories;
use App\Entity\Properties\Demarcheur;
use Doctrine\Persistence\ManagerRegistry;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;

/**
 * @method Categories|null find($id, $lockMode = null, $lockVersion = null)
 * @method Categories|null findOneBy(array $criteria, array $orderBy = null)
 * @method Categories[]    findAll()
 * @method Categories[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
 */
class DemarcheursRepository extends ServiceEntityRepository
{
    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, Demarcheur::class);
    }

    // /**
    //  * @return Categories[] Returns an array of Categories objects
    //  */

    public function findAllOrderByCreationDesc(): array
    {
        return $this->createQueryBuilder('d') // 'd' = alias
            ->orderBy('d.createdAt', 'DESC') // du plus récent au plus ancien
            ->getQuery()
            ->getResult();
    }


    /*
    public function findOneBySomeField($value): ?Categories
    {
        return $this->createQueryBuilder('c')
            ->andWhere('c.exampleField = :val')
            ->setParameter('val', $value)
            ->getQuery()
            ->getOneOrNullResult()
        ;
    }
    */
}
