@@ -46,8 +46,12 @@ class ReminderStore extends AbstractStore implements ReminderStoreInterface | |||
} | |||
// findByUser | |||
public function getByUser(UserInterface $user): array | |||
public function getByUser(UserInterface $user, $query = null): array | |||
{ | |||
if (is_null($query)) { | |||
$query = $this->query->create(); | |||
} | |||
$query = $this->query->create(); | |||
$query | |||
@@ -61,12 +65,15 @@ class ReminderStore extends AbstractStore implements ReminderStoreInterface | |||
// findByEasyAdminConfigAndUser | |||
public function getByEasyAdminConfigAndUser( | |||
$crudAction, | |||
$crudControllerFqcn, | |||
string $crudAction, | |||
string $crudControllerFqcn, | |||
UserInterface $user, | |||
$entityId = null | |||
int $entityId = null, | |||
$query = null | |||
): array { | |||
$query = $this->query->create(); | |||
if (is_null($query)) { | |||
$query = $this->query->create(); | |||
} | |||
$query | |||
->filterByUser($user) |
@@ -3,10 +3,16 @@ | |||
namespace Lc\SovBundle\Repository\Site; | |||
use Knp\Component\Pager\PaginatorInterface; | |||
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait; | |||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||
use Lc\CaracoleBundle\Repository\StatusRepositoryQueryTrait; | |||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | |||
class NewsRepositoryQuery extends AbstractRepositoryQuery implements NewsRepositoryQueryInterface | |||
{ | |||
use StatusRepositoryQueryTrait; | |||
use MerchantRepositoryQueryTrait; | |||
public function __construct(NewsRepository $repository, PaginatorInterface $paginator) | |||
{ | |||
parent::__construct($repository, 'r', $paginator); |
@@ -12,4 +12,36 @@ class NewsStore extends AbstractStore implements NewsStoreInterface | |||
{ | |||
$this->query = $query; | |||
} | |||
//findLatests | |||
public function getLatests(int $maxResults = 0, $query = null): array | |||
{ | |||
if (is_null($query)) { | |||
$query = $this->query->create(); | |||
} | |||
$query | |||
->filterIsOnline() | |||
->orderBy('.date', 'DESC'); | |||
if ($maxResults) { | |||
$query | |||
->limit($maxResults); | |||
} | |||
return $query->find(); | |||
} | |||
public function findLatests($maxResults = 0) | |||
{ | |||
$result = $this->findByMerchantQuery() | |||
->orderBy('e.date', 'DESC'); | |||
$result->andWhere('e.status = 1'); | |||
if ($maxResults) { | |||
$result->setMaxResults($maxResults); | |||
} | |||
return $result->getQuery()->getResult(); | |||
} | |||
} |