瀏覽代碼

New

develop
Charly 3 年之前
父節點
當前提交
0b4012f138
共有 3 個檔案被更改,包括 50 行新增5 行删除
  1. +12
    -5
      Repository/Reminder/ReminderStore.php
  2. +6
    -0
      Repository/Site/NewsRepositoryQuery.php
  3. +32
    -0
      Repository/Site/NewsStore.php

+ 12
- 5
Repository/Reminder/ReminderStore.php 查看文件

@@ -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)

+ 6
- 0
Repository/Site/NewsRepositoryQuery.php 查看文件

@@ -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);

+ 32
- 0
Repository/Site/NewsStore.php 查看文件

@@ -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();
}
}

Loading…
取消
儲存