public function getShipment() { return $this->hasOne(Shipment::className(), ['order_id' => 'order_id']); }
$orderItems = $model->orderItem; foreach ($orderItems as $orderItem) { $orderItemArray .= DetailView::widget(['model' => $orderItem, 'attributes' => ['name', 'price', 'qty', 'picture:image']]); } $orderInfo = DetailView::widget(['model' => $model, 'attributes' => ['total_price', 'shipping_fee', 'payment_fee', 'address', 'memo', 'create_at:datetime', 'update_at:datetime']]); $orderInfo2 = $this->render('_status', ['model' => $model]); if ($model->payment) { $paymentInfo = DetailView::widget(['model' => $model->payment, 'attributes' => ['payment_method', 'payment_fee', 'transcation_no', 'create_at:datetime']]); } else { $paymentInfo = Yii::t('order', 'Not Paid'); } if ($model->payment) { if ($model->shipment) { if ($model->shipment->status != 1) { $shipmentInfo = $this->render('_shipment', ['model' => $model->shipment]); } else { $shipmentInfo = DetailView::widget(['model' => $model->shipment, 'attributes' => ['shipment_method', 'trace_no', 'create_at:datetime']]); } } else { $shipment = Yii::createObject(\star\shipment\models\Shipment::className()); $shipmentInfo = $this->render('_shipment', ['model' => $shipment, 'orderModel' => $model]); } } else { $shipmentInfo = Yii::t('order', 'Not Paid'); } $items = [['label' => Yii::t('order', 'Order'), 'content' => $orderItemArray . $orderInfo . $orderInfo2], ['label' => Yii::t('app', 'Payment'), 'content' => $paymentInfo], ['label' => Yii::t('order', 'Shipment'), 'content' => $shipmentInfo]]; echo Tabs::widget(['items' => $items]); ?> </div>
/** * Finds the Shipment model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Shipment the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Shipment::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }