/var/www/vhosts/nabawater/api/modules/v1/models
Edit: /var/www/vhosts/nabawater/api/modules/v1/models/VendorReportDetail.php (6538B)
function(self $model) {
$modelBranch = Branch::findOne($model->branch_id);
return $modelBranch !== null ? $modelBranch->branch_key : null;
},
'order_datetime' => function(self $model){
$dtHelper = DateTimeHelper::getInstance();
return $dtHelper->format($model->order_date_time, $dtHelper::MYSQL_DATETIME_FORMAT);
},
'order_key',
'order_total',
'commission_amount',
'currency_code',
'first_name' => 'customer_first_name',
'last_name' => 'customer_last_name',
'email' => 'customer_email',
'mobile_number' => 'customer_mobile_number',
'tax' => function(self $model) {
return OrderTax::find()->where(['order_id' => $model->order_id])->all();
},
'sub_total' => 'item_total',
'payment_status',
'promocode' => function(self $model) {
$modelCoupon = OrderCoupon::findOne(['order_id' => $model->order_id]);
return $modelCoupon !== null ? $modelCoupon->coupon_code : null;
},
'product_id',
'products',
'product_price' => function(self $model) {
return [];
},
'product_total_price' => function(self $model) {
return [];
},
'product_quantity' => function(self $model) {
return OrderItem::find()->where(['order_id' => $model->order_id])->count();
},
'delivery_type' => 'order_type',
'delivery_fee',
'delivery_boy_tip',
'cgst_amount' => function (self $model) {
$vat_cgst = $this->isNull($model->vat_cgst);
return empty($vat_cgst) ? 0 : $vat_cgst;
},
'sgst_amount' => function (self $model) {
$vat_sgst = $this->isNull($model->vat_sgst);
return empty($vat_sgst) ? 0 : $vat_sgst;
},
'igst_amount' => function (self $model) {
$vat_sgst = $this->isNull($model->vat_igst);
return empty($vat_igst) ? 0 : $vat_igst;
},
'delivery_city' => function(self $model) {
$modelAddress = [];
if ( (int)$model->order_type === $model::ORDER_TYPE_DELIVERY ) {
$modelAddress = self::getUserAddress();
}
return isset($modelAddress->state) ? $modelAddress->state : null;
},
'delivery_area' => function(self $model) {
$modelAddress = [];
if ( (int)$model->order_type === $model::ORDER_TYPE_DELIVERY ) {
$modelAddress = self::getUserAddress();
}
return isset($modelAddress->area) ? $modelAddress->area : null;
},
'flat_no',
'apartment',
'delivery_instruction' => function(self $model) {
$modelAddress = [];
if ( (int)$model->order_type === $model::ORDER_TYPE_DELIVERY ) {
$modelAddress = self::getUserAddress();
}
return isset($modelAddress->address_remark) ? $modelAddress->address_remark : null;
},
'message' => function (self $model) {
return ($model->order_message) ? $model->order_message : '';
},
'alternate_contact' => function(self $model) {
$modelAddress = [];
if ( (int)$model->order_type === $model::ORDER_TYPE_DELIVERY ) {
$modelAddress = $model->getUserAddress();
}
return isset($modelAddress->contact_number) ? $modelAddress->contact_number : null;
},
'landmark',
'payment_type' => 'payment_option',
'delivery_status' => 'order_status',
'postal_code',
'package_price',
'order_id',
'delivery_address' => function(self $model) {
$modelAddress = [];
if ( (int)$model->order_type === $model::ORDER_TYPE_DELIVERY ) {
$modelAddress = self::getUserAddress();
}
return isset($modelAddress->address) ? $modelAddress->address : null;
},
'delivery_timing' => 'delivery_option',
'later_datetime' => 'pickup_delivery_date_time',
'delivery_minutes',
'rejected_reason',
'item_name' => function(self $model) {
return [];
},
'item_quantity' => function(self $model) {
return [];
},
];
}
public function getUserAddress()
{
return UserAddress::findOne($this->user_address_id);
}
/**
*
* @return type
*/
public function getOrderItemName()
{
$orderItemName = VendorOrderItem::find()->alias('OI')
->select(['OI.quantity','OI.item_total_price','OIM.item_image_path','OIM.order_item_id'])
->leftJoin(['OIM' => OrderItemImage::tableName()],'OIM.order_item_id = OI.order_item_id')
->where(['OI.order_id' => $this->order_id]);
OrderItem::selectTranslation($orderItemName);
return $orderItemName->all();
}
}