public function actionRequests() { return $this->render(['items' => \app\models\Shop\Request::query(['bog_shop_requests.user_id' => \Yii::$app->user->id])->select(['bog_shop_requests.*', 'bog_shop_product.name as product_name', 'bog_shop_product.image as product_image'])->innerJoin('bog_shop_product', 'bog_shop_product.id = bog_shop_requests.product_id')->all()]); }
public function actionRequests() { return $this->render(['items' => \app\models\Shop\Request::query(['user_id' => \Yii::$app->user->id])->all()]); }
} }); \$('.rowTable').click(function() { window.location = '/admin/requests/' + \$(this).data('id'); }); JS ); ?> <div class="container"> <h1 class="page-header">Заказы</h1> <?php echo \yii\grid\GridView::widget(['dataProvider' => new \yii\data\ActiveDataProvider(['query' => \app\models\Shop\Request::query()->innerJoin('gs_users', 'gs_users.id = bog_shop_requests.user_id')->select(['bog_shop_requests.*', 'gs_users.name_first as user_name_first', 'gs_users.avatar as user_avatar', 'gs_users.email as user_email', 'gs_users.name_last as user_name_last'])->orderBy(['last_message_time' => SORT_DESC]), 'pagination' => ['pageSize' => 50]]), 'tableOptions' => ['class' => 'table table-hover table-striped'], 'rowOptions' => function ($item) { return ['role' => 'button', 'data-id' => $item['id'], 'class' => 'rowTable']; }, 'columns' => ['id', 'address:text:Адрес', 'phone:text:Телефон', ['header' => 'Пользоватль', 'content' => function ($model, $key, $index, $column) { $arr = []; $arr[] = $model['user_email'] . ' ' . $model['user_name_first'] . ' ' . $model['user_name_last']; return join('', $arr); }], ['header' => 'Время создания', 'content' => function ($model, $key, $index, $column) { $v = \yii\helpers\ArrayHelper::getValue($model, 'date_create', 0); if ($v == 0) { return ''; } return Html::tag('abbr', \cs\services\DatePeriod::back($v, ['isShort' => true]), ['class' => 'gsssTooltip', 'title' => Yii::$app->formatter->asDatetime($v)]); }], ['header' => 'Время последнего ответа', 'content' => function ($model, $key, $index, $column) { $v = \yii\helpers\ArrayHelper::getValue($model, 'last_message_time', 0); if ($v == 0) { return '';
public function actionIndex() { return $this->render(['items' => Request::query()->orderBy(['date_create' => SORT_DESC])->all()]); }