diff --git a/frontend/controllers/CabinetController.php b/frontend/controllers/CabinetController.php index a978cba..9f5b641 100755 --- a/frontend/controllers/CabinetController.php +++ b/frontend/controllers/CabinetController.php @@ -9,6 +9,7 @@ use frontend\models\UserPassport; use yii\filters\AccessControl; use yii\filters\VerbFilter; + use yii\helpers\VarDumper; use yii\web\Controller; use yii\web\NotFoundHttpException; @@ -144,9 +145,20 @@ public function actionArrivals() { - $reports = Report::find() - ->with('intellectualProperty') - ->all(); + /** + * @var User $user + */ + $user = \Yii::$app->user->identity; + if ($user->isAdmin()) { + $reports = Report::find() + ->with('intellectualProperty') + ->all(); + } else { + $reports = Report::find() + ->joinWith('intellectualProperty.creativeRoles') + ->where([ 'creative_role.user_id' => $user->id ]) + ->all(); + } return $this->render( 'arrivals', [ @@ -157,8 +169,20 @@ public function actionNotifications() { - $table = Report::find() - ->all(); + /** + * @var User $user + */ + $user = \Yii::$app->user->identity; + if ($user->isAdmin()) { + $table = Report::find() + ->with('intellectualProperty') + ->all(); + } else { + $table = Report::find() + ->joinWith('intellectualProperty.creativeRoles') + ->where([ 'creative_role.user_id' => $user->id ]) + ->all(); + } return $this->render( 'notifications', [ diff --git a/frontend/views/cabinet/arrivals.php b/frontend/views/cabinet/arrivals.php index bda8813..e77392f 100755 --- a/frontend/views/cabinet/arrivals.php +++ b/frontend/views/cabinet/arrivals.php @@ -1,4 +1,5 @@ user->identity; ?>