<?php

namespace App\Repository;

use App\Entity\BlogPost;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**
 * @extends ServiceEntityRepository<BlogPost>
 */
class BlogPostRepository extends ServiceEntityRepository
{
    public function __construct(ManagerRegistry $registry) {
        parent::__construct($registry, BlogPost::class);
    }

    /**
    * @return BlogPost[]
    */
    public function findAllOrderedBySlugDesc(): array
    {
        return $this->createQueryBuilder('n')
            ->orderBy('n.slug', 'DESC')
            ->getQuery()
            ->getResult();
        }
}
