From fdce5f4affa3867439a4beef2b51c21f69417482 Mon Sep 17 00:00:00 2001 From: Anastasia Date: Fri, 13 Apr 2018 11:50:12 +0300 Subject: [PATCH] - order --- controllers/OrderController.php | 139 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------- labels/Module.php | 8 ++++++++ labels/controllers/DeliveryController.php | 175 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ labels/controllers/LabelController.php | 169 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ labels/controllers/PaymentController.php | 175 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ labels/models/Delivery.php | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ labels/models/DeliveryLang.php | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ labels/models/Label.php | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ labels/models/LabelLang.php | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ labels/models/Payment.php | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ labels/models/PaymentLang.php | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ models/Order.php | 3 +++ 12 files changed, 1274 insertions(+), 65 deletions(-) create mode 100755 labels/Module.php create mode 100644 labels/controllers/DeliveryController.php create mode 100644 labels/controllers/LabelController.php create mode 100644 labels/controllers/PaymentController.php create mode 100755 labels/models/Delivery.php create mode 100755 labels/models/DeliveryLang.php create mode 100755 labels/models/Label.php create mode 100755 labels/models/LabelLang.php create mode 100755 labels/models/Payment.php create mode 100755 labels/models/PaymentLang.php diff --git a/controllers/OrderController.php b/controllers/OrderController.php index 13c5c25..89bf65c 100755 --- a/controllers/OrderController.php +++ b/controllers/OrderController.php @@ -3,13 +3,13 @@ namespace artbox\order\controllers; use artbox\catalog\models\Variant; - use artbox\order\models\Delivery; - use artbox\order\models\Label; + use artbox\core\admin\actions\Index; + use artbox\order\labels\models\Delivery; + use artbox\order\labels\models\Label; use artbox\order\models\OrderProduct; - use artbox\order\models\Payment; + use artbox\order\labels\models\Payment; use Yii; use artbox\order\models\Order; - use artbox\order\models\OrderSearch; use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; @@ -25,6 +25,11 @@ /** * @inheritdoc */ + public function getViewPath() + { + return '@artbox/order/views/order'; + } + public function behaviors() { return [ @@ -53,39 +58,43 @@ ]; } - /** - * Lists all Order models. - * - * @return mixed - */ - public function actionIndex() + public function actions() { - $searchModel = new OrderSearch(); - $dataProvider = $searchModel->search(Yii::$app->request->queryParams); - $labels = Label::find() - ->select( - [ - 'title', - 'id', - ] - ) - ->joinWith('lang') - ->andWhere( - [ - 'status' => true, - ] - ) - ->indexBy('id') - ->column(); - - return $this->render( - 'index', - [ - 'searchModel' => $searchModel, - 'dataProvider' => $dataProvider, - 'labels' => $labels, - ] - ); + return [ + 'index' => [ + 'class' => Index::className(), + 'columns' => [ + 'name' => [ + 'type' => Index::ACTION_COL, + ], + 'phone' => [ + 'type' => Index::STRING_COL, + ], + 'email' => [ + 'type' => Index::STRING_COL, + ], + 'label' => [ + 'type' => Index::RELATION_COL, + 'columnConfig' => [ + 'relationField' => 'title', + ], + ], + 'created_at' => [ + 'type' => Index::DATETIME_COL, + ], + 'sort' => [ + 'type' => Index::POSITION_COL, + ], + 'status' => [ + 'type' => Index::STATUS_COL, + ], + ], + 'model' => Order::className(), + 'hasLanguage' => false, + 'enableMassDelete' => false, + 'modelPrimaryKey' => 'id', + ], + ]; } /** @@ -145,50 +154,50 @@ ); } else { $labels = Label::find() - ->joinWith('lang') - ->select( + ->joinWith('language') + ->select( [ 'title', 'id', ] ) - ->where( + ->where( [ 'status' => true, ] ) - ->indexBy('id') - ->column(); + ->indexBy('id') + ->column(); $deliveries = Delivery::find() - ->joinWith('lang') - ->select( + ->joinWith('language') + ->select( [ 'title', 'id', ] ) - ->where( + ->where( [ 'status' => true, ] ) - ->indexBy('id') - ->column(); + ->indexBy('id') + ->column(); $payments = Payment::find() - ->joinWith('lang') - ->select( + ->joinWith('language') + ->select( [ 'title', 'id', ] ) - ->where( + ->where( [ 'status' => true, ] ) - ->indexBy('id') - ->column(); + ->indexBy('id') + ->column(); return $this->render( 'create', [ @@ -224,7 +233,7 @@ ); } else { $labels = Label::find() - ->joinWith('lang') + ->joinWith('language') ->select( [ 'title', @@ -239,35 +248,35 @@ ->indexBy('id') ->column(); $deliveries = Delivery::find() - ->joinWith('lang') - ->select( + ->joinWith('language') + ->select( [ 'title', 'id', ] ) - ->where( + ->where( [ 'status' => true, ] ) - ->indexBy('id') - ->column(); + ->indexBy('id') + ->column(); $payments = Payment::find() - ->joinWith('lang') - ->select( + ->joinWith('language') + ->select( [ 'title', 'id', ] ) - ->where( + ->where( [ 'status' => true, ] ) - ->indexBy('id') - ->column(); + ->indexBy('id') + ->column(); return $this->render( 'update', [ @@ -448,7 +457,7 @@ protected function getLabels() { return Label::find() - ->joinWith('lang') + ->joinWith('language') ->select( [ 'title', @@ -470,7 +479,7 @@ protected function getPayments() { return Payment::find() - ->joinWith('lang') + ->joinWith('language') ->select( [ 'title', @@ -492,7 +501,7 @@ protected function getDeliveries() { return Delivery::find() - ->joinWith('lang') + ->joinWith('language') ->select( [ 'title', diff --git a/labels/Module.php b/labels/Module.php new file mode 100755 index 0000000..3c473a6 --- /dev/null +++ b/labels/Module.php @@ -0,0 +1,8 @@ + [ + 'class' => Index::className(), + 'columns' => [ + 'title' => [ + 'type' => Index::ACTION_COL, + ], + 'sort' => [ + 'type' => Index::POSITION_COL, + ], + 'status' => [ + 'type' => Index::STATUS_COL, + ], + ], + 'model' => Delivery::className(), + 'hasLanguage' => true, + 'enableMassDelete' => true, + 'modelPrimaryKey' => 'id', + ], + 'create' => array_merge([ 'class' => Create::className() ], self::fieldsConfig()), + 'update' => array_merge([ 'class' => Update::className() ], self::fieldsConfig()), + 'view' => [ + 'class' => View::className(), + 'model' => Delivery::className(), + 'hasAlias' => false, + 'hasGallery' => false, + 'languageFields' => [ + [ + 'name' => 'title', + 'type' => Form::STRING, + ], + [ + 'name' => 'description', + 'type' => Form::WYSIWYG, + ], + ], + 'fields' => [ + [ + 'name' => 'status', + 'type' => Form::BOOL, + ], + [ + 'name' => 'sort', + 'type' => Form::NUMBER, + ], + [ + 'name' => 'value', + 'type' => Form::NUMBER, + ], + [ + 'name' => 'color', + 'type' => Form::STRING, + ], + [ + 'name' => 'default', + 'type' => Form::BOOL, + ], + ], + ], + 'delete' => [ + 'class' => Delete::className(), + ], + ]; + } + + public function findModel($id) + { + $model = Delivery::find() + ->with('languages') + ->where([ 'id' => $id ]) + ->one(); + if ($model !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } + + public function newModel() + { + return new Delivery(); + } + + public function deleteModel($id) + { + $page = Delivery::find() + ->with('languages') + ->where( + [ + 'id' => $id, + ] + ) + ->one(); + $langs = call_user_func( + [ + $page, + 'getVariationModels', + ] + ); + foreach ($langs as $lang) { + if ($lang->alias !== null) { + $lang->alias->delete(); + } + } + + return $page->delete(); + } + + protected static function fieldsConfig() + { + return [ + 'model' => Delivery::className(), + 'hasAlias' => false, + 'hasGallery' => false, + 'languageFields' => [ + [ + 'name' => 'title', + 'type' => Form::STRING, + ], + [ + 'name' => 'description', + 'type' => Form::WYSIWYG, + ], + ], + 'fields' => [ + [ + 'name' => 'status', + 'type' => Form::BOOL, + ], + [ + 'name' => 'sort', + 'type' => Form::NUMBER, + ], + [ + 'name' => 'value', + 'type' => Form::NUMBER, + ], + [ + 'name' => 'color', + 'type' => Form::STRING, + ], + [ + 'name' => 'default', + 'type' => Form::BOOL, + ], + + ], + ]; + } + } \ No newline at end of file diff --git a/labels/controllers/LabelController.php b/labels/controllers/LabelController.php new file mode 100644 index 0000000..49003d4 --- /dev/null +++ b/labels/controllers/LabelController.php @@ -0,0 +1,169 @@ + [ + 'class' => Index::className(), + 'columns' => [ + 'title' => [ + 'type' => Index::ACTION_COL, + ], + 'sort' => [ + 'type' => Index::POSITION_COL, + ], + 'status' => [ + 'type' => Index::STATUS_COL, + ], + ], + 'model' => Label::className(), + 'hasLanguage' => true, + 'enableMassDelete' => true, + 'modelPrimaryKey' => 'id', + ], + 'create' => array_merge([ 'class' => Create::className() ], self::fieldsConfig()), + 'update' => array_merge([ 'class' => Update::className() ], self::fieldsConfig()), + 'view' => [ + 'class' => View::className(), + 'model' => Label::className(), + 'hasAlias' => false, + 'hasGallery' => false, + 'languageFields' => [ + [ + 'name' => 'title', + 'type' => Form::STRING, + ], + [ + 'name' => 'description', + 'type' => Form::WYSIWYG, + ], + ], + 'fields' => [ + [ + 'name' => 'status', + 'type' => Form::BOOL, + ], + [ + 'name' => 'sort', + 'type' => Form::NUMBER, + ], + [ + 'name' => 'value', + 'type' => Form::NUMBER, + ], + [ + 'name' => 'color', + 'type' => Form::STRING, + ], + [ + 'name' => 'default', + 'type' => Form::BOOL, + ], + ], + ], + 'delete' => [ + 'class' => Delete::className(), + ], + ]; + } + + public function findModel($id) + { + $model = Label::find() + ->with('languages') + ->where([ 'id' => $id ]) + ->one(); + if ($model !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } + + public function newModel() + { + return new Label(); + } + + public function deleteModel($id) + { + $page = Label::find() + ->with('languages') + ->where( + [ + 'id' => $id, + ] + ) + ->one(); + $langs = call_user_func( + [ + $page, + 'getVariationModels', + ] + ); + foreach ($langs as $lang) { + if ($lang->alias !== null) { + $lang->alias->delete(); + } + } + + return $page->delete(); + } + + protected static function fieldsConfig() + { + return [ + 'model' => Label::className(), + 'hasAlias' => false, + 'hasGallery' => false, + 'languageFields' => [ + [ + 'name' => 'title', + 'type' => Form::STRING, + ], + [ + 'name' => 'description', + 'type' => Form::WYSIWYG, + ], + ], + 'fields' => [ + [ + 'name' => 'status', + 'type' => Form::BOOL, + ], + [ + 'name' => 'sort', + 'type' => Form::NUMBER, + ], + [ + 'name' => 'value', + 'type' => Form::NUMBER, + ], + [ + 'name' => 'color', + 'type' => Form::STRING, + ], + [ + 'name' => 'default', + 'type' => Form::BOOL, + ], + + ], + ]; + } + } \ No newline at end of file diff --git a/labels/controllers/PaymentController.php b/labels/controllers/PaymentController.php new file mode 100644 index 0000000..fb656a4 --- /dev/null +++ b/labels/controllers/PaymentController.php @@ -0,0 +1,175 @@ + [ + 'class' => Index::className(), + 'columns' => [ + 'title' => [ + 'type' => Index::ACTION_COL, + ], + 'sort' => [ + 'type' => Index::POSITION_COL, + ], + 'status' => [ + 'type' => Index::STATUS_COL, + ], + ], + 'model' => Payment::className(), + 'hasLanguage' => true, + 'enableMassDelete' => true, + 'modelPrimaryKey' => 'id', + ], + 'create' => array_merge([ 'class' => Create::className() ], self::fieldsConfig()), + 'update' => array_merge([ 'class' => Update::className() ], self::fieldsConfig()), + 'view' => [ + 'class' => View::className(), + 'model' => Payment::className(), + 'hasAlias' => false, + 'hasGallery' => false, + 'languageFields' => [ + [ + 'name' => 'title', + 'type' => Form::STRING, + ], + [ + 'name' => 'description', + 'type' => Form::WYSIWYG, + ], + ], + 'fields' => [ + [ + 'name' => 'status', + 'type' => Form::BOOL, + ], + [ + 'name' => 'sort', + 'type' => Form::NUMBER, + ], + [ + 'name' => 'value', + 'type' => Form::NUMBER, + ], + [ + 'name' => 'color', + 'type' => Form::STRING, + ], + [ + 'name' => 'default', + 'type' => Form::BOOL, + ], + ], + ], + 'delete' => [ + 'class' => Delete::className(), + ], + ]; + } + + public function findModel($id) + { + $model = Payment::find() + ->with('languages') + ->where([ 'id' => $id ]) + ->one(); + if ($model !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } + + public function newModel() + { + return new Payment(); + } + + public function deleteModel($id) + { + $page = Payment::find() + ->with('languages') + ->where( + [ + 'id' => $id, + ] + ) + ->one(); + $langs = call_user_func( + [ + $page, + 'getVariationModels', + ] + ); + foreach ($langs as $lang) { + if ($lang->alias !== null) { + $lang->alias->delete(); + } + } + + return $page->delete(); + } + + protected static function fieldsConfig() + { + return [ + 'model' => Payment::className(), + 'hasAlias' => false, + 'hasGallery' => false, + 'languageFields' => [ + [ + 'name' => 'title', + 'type' => Form::STRING, + ], + [ + 'name' => 'description', + 'type' => Form::WYSIWYG, + ], + ], + 'fields' => [ + [ + 'name' => 'status', + 'type' => Form::BOOL, + ], + [ + 'name' => 'sort', + 'type' => Form::NUMBER, + ], + [ + 'name' => 'value', + 'type' => Form::NUMBER, + ], + [ + 'name' => 'color', + 'type' => Form::STRING, + ], + [ + 'name' => 'default', + 'type' => Form::BOOL, + ], + + ], + ]; + } + } \ No newline at end of file diff --git a/labels/models/Delivery.php b/labels/models/Delivery.php new file mode 100755 index 0000000..3d7124f --- /dev/null +++ b/labels/models/Delivery.php @@ -0,0 +1,126 @@ + [ + 'class' => VariationBehavior::className(), + 'variationsRelation' => 'languages', + 'defaultVariationRelation' => 'language', + 'variationOptionReferenceAttribute' => 'language_id', + 'optionModelClass' => Language::className(), + 'defaultVariationOptionReference' => function () { + return Language::getCurrent()->id; + }, + 'optionQueryFilter' => function (ActiveQuery $query) { + $query->where( + [ + 'status' => true, + ] + ); + }, + ], + 'positionBehavior' => [ + 'class' => PositionBehavior::className(), + 'positionAttribute' => 'sort', + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ 'sort' ], + 'integer', + ], + [ + [ 'value' ], + 'number', + ], + [ + [ 'status' ], + 'boolean', + ], + [ + [ 'default' ], + 'boolean', + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => Yii::t('order', 'ID'), + 'sort' => Yii::t('order', 'Sort'), + 'value' => Yii::t('order', 'Value'), + 'status' => Yii::t('order', 'Status'), + 'default' => Yii::t('order', 'Default'), + ]; + } + + public function getLanguages() + { + return $this->hasMany(DeliveryLang::className(), [ 'delivery_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLanguage() + { + return $this->hasOne(DeliveryLang::className(), [ 'delivery_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getOrders() + { + return $this->hasMany(Order::className(), [ 'delivery_id' => 'id' ]); + } + } diff --git a/labels/models/DeliveryLang.php b/labels/models/DeliveryLang.php new file mode 100755 index 0000000..5b6319a --- /dev/null +++ b/labels/models/DeliveryLang.php @@ -0,0 +1,95 @@ + 255, + ], + [ + [ 'delivery_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Delivery::className(), + 'targetAttribute' => [ 'delivery_id' => 'id' ], + ], + [ + [ 'language_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Language::className(), + 'targetAttribute' => [ 'language_id' => 'id' ], + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'delivery_id' => Yii::t('order', 'Delivery ID'), + 'language_id' => Yii::t('order', 'Language ID'), + 'title' => Yii::t('order', 'Title'), + 'description' => Yii::t('order', 'Description'), + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getDelivery() + { + return $this->hasOne(Delivery::className(), [ 'id' => 'delivery_id' ]); + } + + } diff --git a/labels/models/Label.php b/labels/models/Label.php new file mode 100755 index 0000000..53ca2ff --- /dev/null +++ b/labels/models/Label.php @@ -0,0 +1,132 @@ + [ + 'class' => VariationBehavior::className(), + 'variationsRelation' => 'languages', + 'defaultVariationRelation' => 'language', + 'variationOptionReferenceAttribute' => 'language_id', + 'optionModelClass' => Language::className(), + 'defaultVariationOptionReference' => function () { + return Language::getCurrent()->id; + }, + 'optionQueryFilter' => function (ActiveQuery $query) { + $query->where( + [ + 'status' => true, + ] + ); + }, + ], + 'positionBehavior' => [ + 'class' => PositionBehavior::className(), + 'positionAttribute' => 'sort', + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ 'sort' ], + 'integer', + ], + [ + [ 'color' ], + 'string', + ], + [ + [ 'value' ], + 'number', + ], + [ + [ 'status' ], + 'boolean', + ], + [ + [ 'default' ], + 'boolean', + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => Yii::t('order', 'ID'), + 'sort' => Yii::t('order', 'Sort'), + 'value' => Yii::t('order', 'Value'), + 'status' => Yii::t('order', 'Status'), + 'color' => Yii::t('order', 'Color'), + 'default' => Yii::t('order', 'Default'), + ]; + } + + public function getLanguages() + { + return $this->hasMany(LabelLang::className(), [ 'label_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLanguage() + { + return $this->hasOne(LabelLang::className(), [ 'label_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getOrders() + { + return $this->hasMany(Order::className(), [ 'label_id' => 'id' ]); + } + } diff --git a/labels/models/LabelLang.php b/labels/models/LabelLang.php new file mode 100755 index 0000000..b028376 --- /dev/null +++ b/labels/models/LabelLang.php @@ -0,0 +1,102 @@ + 255, + ], + [ + [ 'label_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Label::className(), + 'targetAttribute' => [ 'label_id' => 'id' ], + ], + [ + [ 'language_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Language::className(), + 'targetAttribute' => [ 'language_id' => 'id' ], + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'label_id' => Yii::t('order', 'Label ID'), + 'language_id' => Yii::t('order', 'Language ID'), + 'title' => Yii::t('order', 'Title'), + 'description' => Yii::t('order', 'Description'), + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLabel() + { + return $this->hasOne(Label::className(), [ 'id' => 'label_id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLanguage() + { + return $this->hasOne(Language::className(), [ 'id' => 'language_id' ]); + } + } diff --git a/labels/models/Payment.php b/labels/models/Payment.php new file mode 100755 index 0000000..53ca338 --- /dev/null +++ b/labels/models/Payment.php @@ -0,0 +1,121 @@ + [ + 'class' => VariationBehavior::className(), + 'variationsRelation' => 'languages', + 'defaultVariationRelation' => 'language', + 'variationOptionReferenceAttribute' => 'language_id', + 'optionModelClass' => Language::className(), + 'defaultVariationOptionReference' => function () { + return Language::getCurrent()->id; + }, + 'optionQueryFilter' => function (ActiveQuery $query) { + $query->where( + [ + 'status' => true, + ] + ); + }, + ], + 'positionBehavior' => [ + 'class' => PositionBehavior::className(), + 'positionAttribute' => 'sort', + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ 'sort' ], + 'integer', + ], + [ + [ 'status' ], + 'boolean', + ], + [ + [ 'default' ], + 'boolean', + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => Yii::t('order', 'ID'), + 'sort' => Yii::t('order', 'Sort'), + 'status' => Yii::t('order', 'Status'), + 'default' => Yii::t('order', 'Default'), + ]; + } + + public function getLanguages() + { + return $this->hasMany(PaymentLang::className(), [ 'payment_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLanguage() + { + return $this->hasOne(PaymentLang::className(), [ 'payment_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getOrders() + { + return $this->hasMany(Order::className(), [ 'payment_id' => 'id' ]); + } + + } diff --git a/labels/models/PaymentLang.php b/labels/models/PaymentLang.php new file mode 100755 index 0000000..56947e4 --- /dev/null +++ b/labels/models/PaymentLang.php @@ -0,0 +1,94 @@ + 255, + ], + [ + [ 'language_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Language::className(), + 'targetAttribute' => [ 'language_id' => 'id' ], + ], + [ + [ 'payment_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Payment::className(), + 'targetAttribute' => [ 'payment_id' => 'id' ], + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'payment_id' => Yii::t('order', 'Payment ID'), + 'language_id' => Yii::t('order', 'Language ID'), + 'title' => Yii::t('order', 'Title'), + 'description' => Yii::t('order', 'Description'), + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getPayment() + { + return $this->hasOne(Payment::className(), [ 'id' => 'payment_id' ]); + } + } diff --git a/models/Order.php b/models/Order.php index 442cb67..6e02aa3 100755 --- a/models/Order.php +++ b/models/Order.php @@ -5,6 +5,9 @@ use Yii; use yii\behaviors\TimestampBehavior; use yii\db\ActiveRecord; + use artbox\order\labels\models\Label; + use artbox\order\labels\models\Payment; + use artbox\order\labels\models\Delivery; /** * This is the model class for table "order". -- libgit2 0.21.4