From 6628fe31f5e7bcb98c38eab2b03b46119807d2fc Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 11 May 2017 15:57:56 +0300 Subject: [PATCH] -User's order page in process --- frontend/controllers/AccountController.php | 32 +++++++++++++++++++++++++++----- frontend/views/account/index.php | 22 ++++++++++++++++++---- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/frontend/controllers/AccountController.php b/frontend/controllers/AccountController.php index 040ddf7..1a25d20 100644 --- a/frontend/controllers/AccountController.php +++ b/frontend/controllers/AccountController.php @@ -3,7 +3,10 @@ namespace frontend\controllers; use artbox\order\models\Customer; + use artbox\order\models\Order; use yii\web\Controller; + use yii\web\ForbiddenHttpException; + use yii\web\NotFoundHttpException; /** * Class AccountController @@ -14,15 +17,12 @@ { public function actionIndex() { - /** - * @var Customer $user - */ - $user = \Yii::$app->user->identity; + $user = Customer::findOne(\Yii::$app->user->identity->getId()); $orders = $user->getOrders() ->with( [ - 'label', + 'label.lang', 'orderProducts', ] ) @@ -40,4 +40,26 @@ ] ); } + + public function actionOrder($id) + { + /** + * @var Order $order + */ + $order = Order::find() + ->with('orderProducts') + ->where( + [ + 'id' => $id, + ] + ) + ->one(); + + if (empty($order)) { + throw new NotFoundHttpException(\Yii::t('app', 'Order not found')); + } elseif ($order->user_id !== \Yii::$app->user->identity->getId()) { + throw new ForbiddenHttpException(); + } + + } } \ No newline at end of file diff --git a/frontend/views/account/index.php b/frontend/views/account/index.php index 8f41d94..5e1d94e 100644 --- a/frontend/views/account/index.php +++ b/frontend/views/account/index.php @@ -1,6 +1,7 @@ id; ?> created_at); ?> - 150.00 - Готовится - - Посмотреть + + label)) { ?> + Не задан + + + + label->lang->title ?> + + + Посмотреть -- libgit2 0.21.4