|
- <?php
-
-
-
- namespace backend\controllers;
-
- use yii\filters\AccessControl;
- use yii\filters\VerbFilter;
-
-
- class DashboardController extends BackendController
- {
-
-
- public function behaviors()
- {
- return [
- 'access' => [
- 'class' => AccessControl::class,
- 'rules' => [
- [
- 'allow' => true,
- 'roles' => ['@'],
- 'matchCallback' => function ($rule, $action) {
- return $this->getUserModule()
- ->getAuthorizationChecker()
- ->isGrantedAsProducer($this->getUserCurrent());
- }
- ],
- ],
- ],
- ];
- }
-
-
-
- public function actionIndex()
- {
- return $this->render('index', [
- 'producer' => $this->getProducerCurrent(),
- 'productsCount' => $this->getProductModule()->getRepository()->countProducts(),
- 'pointsSaleCount' => $this->getPointSaleModule()->getRepository()->countPointSales(),
- 'distributionsArray' => $this->getDistributionModule()->getRepository()->findDistributionsDashboard(),
- 'ordersArray' => $this->getOrderModule()->getRepository()->findOrdersDashboard(),
- 'subscriptionsLatestAddedArray' => $this->getSubscriptionModule()->getRepository()->findSubscriptionsLatestAdded(),
- 'forumDiscussionsArray' => \Yii::$app->forumFlarumClient->getLastDiscussions()
- ]);
- }
- }
|