public function actionGetCard($cid) { $company = Company::find()->where(['id' => $cid])->asArray()->one(); $address = Address::find()->where(['id' => $company['address_id']])->asArray()->one(); $shedule = Shedule::find()->where(['company_id' => $cid])->asArray()->all(); $brand = Company::find()->where(['id' => $cid])->one()->brand; $service = Company::find()->where(['id' => $cid])->one()->service; $srv = ArrayHelper::getColumn($service, 'category_id'); $category = Category::find()->where(['id' => $srv])->asArray()->indexBy('id')->all(); $srv = ArrayHelper::map($service, 'id', 'name', 'category_id'); $spoffer = SpecialOffer::find()->where(['company_id' => $cid])->asArray()->one(); $file = Files::find()->where(['id' => $spoffer['file_id']])->asArray()->one(); Yii::$app->response->format = Response::FORMAT_JSON; $response = ['company' => $company, 'address' => $address, 'shedule' => $shedule, 'brand' => $brand, 'category' => $category, 'service' => $srv, 'spoffer' => $spoffer, 'file' => $file]; return $response; }
public function actionRemoveSpecialOffer() { $status = "OK"; $data = Yii::$app->request->post(); $sp = new SpecialOffer(); $ok = $sp->removeSpecialOffer($data['cid']); if (!$ok) { $status = "ERROR"; } Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $responce = ['status' => $status]; return $responce; }
public function hasOffer() { $result = $this->hasOne(SpecialOffer::className(), ['company_id' => 'id']); return $result->count() > 0; }