1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* WellCommerce Open-Source E-Commerce Platform |
4
|
|
|
* |
5
|
|
|
* This file is part of the WellCommerce package. |
6
|
|
|
* |
7
|
|
|
* (c) Adam Piotrowski <[email protected]> |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, |
10
|
|
|
* please view the LICENSE file that was distributed with this source code. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace WellCommerce\Bundle\AppBundle\Controller\Admin; |
14
|
|
|
|
15
|
|
|
use Doctrine\Common\Collections\Collection; |
16
|
|
|
use Doctrine\Common\Collections\Criteria; |
17
|
|
|
use Symfony\Component\HttpFoundation\Response; |
18
|
|
|
use WellCommerce\Bundle\CoreBundle\Controller\AbstractController; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Class DashboardController |
22
|
|
|
* |
23
|
|
|
* @author Adam Piotrowski <[email protected]> |
24
|
|
|
*/ |
25
|
|
|
class DashboardController extends AbstractController |
26
|
|
|
{ |
27
|
|
|
public function indexAction(): Response |
28
|
|
|
{ |
29
|
|
|
return $this->displayTemplate('index', [ |
30
|
|
|
'reviews' => $this->getReviews(), |
31
|
|
|
'orders' => $this->getOrders(), |
32
|
|
|
'clients' => $this->getClients(), |
33
|
|
|
'carts' => $this->getCarts(), |
34
|
|
|
]); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
protected function getReviews(): array |
38
|
|
|
{ |
39
|
|
|
return $this->get('review.repository')->findBy([ |
40
|
|
|
'enabled' => true, |
41
|
|
|
], ['createdAt' => 'desc'], 10); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
protected function getOrders(): array |
45
|
|
|
{ |
46
|
|
|
return $this->get('order.repository')->findBy([ |
47
|
|
|
'confirmed' => true, |
48
|
|
|
'shop' => $this->getShopStorage()->getCurrentShop(), |
49
|
|
|
], ['createdAt' => 'desc'], 10); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
protected function getClients(): array |
53
|
|
|
{ |
54
|
|
|
return $this->get('client.repository')->findBy([ |
55
|
|
|
'shop' => $this->getShopStorage()->getCurrentShop(), |
56
|
|
|
], ['createdAt' => 'desc'], 10); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
protected function getCarts(): Collection |
60
|
|
|
{ |
61
|
|
|
$criteria = new Criteria(); |
62
|
|
|
$criteria->where($criteria->expr()->eq('confirmed', false)); |
63
|
|
|
$criteria->andWhere($criteria->expr()->eq('shop', $this->getShopStorage()->getCurrentShop())); |
64
|
|
|
$criteria->andWhere($criteria->expr()->neq('client', null)); |
65
|
|
|
$criteria->andWhere($criteria->expr()->gt('productTotal.quantity', 0)); |
66
|
|
|
$criteria->orderBy(['createdAt' => 'desc']); |
67
|
|
|
$criteria->setMaxResults(30); |
68
|
|
|
|
69
|
|
|
return $this->get('order.repository')->matching($criteria); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|