public function add() { if ($this->validate()) { $organization = new Organizations(); $organization->official_name = $this->official_name; $organization->nice_name = $this->nice_name; $organization->cyr_name = $this->cyr_name; $organization->overdraft_limit = $this->overdraft; $organization->outbalance_limit = $this->outbalance; $organization->ratio = $this->ratio; $logo_file = UploadedFile::getInstance($this, 'logo'); if ($logo_file) { $file_name = $logo_file->baseName . '.' . $logo_file->extension; $organization->logo = $file_name; } if ($organization->save()) { if ($logo_file) { $folder_path = Yii::$app->params['org_img_path'] . '/' . $organization->id; mkdir($folder_path); $logo_file->saveAs($folder_path . '/' . $file_name); } $this->addOwnersRelations($organization->id); return true; } } return false; }
public function edit(Organizations $org) { $org->official_name = $this->official_name; $org->nice_name = $this->nice_name; $org->cyr_name = $this->cyr_name; $org->outbalance_limit = $this->outbalance; $org->overdraft_limit = $this->overdraft; $org->ratio = $this->ratio; return $org->save(); }
public function actionChangeStatus() { $id = (int) Yii::$app->request->get('id'); $status = Yii::$app->request->get('status'); if ($id && isset($status)) { Organizations::updateAll(['status' => (int) $status], ['id' => $id]); } return $this->redirect('/organizations'); }
/** * @return \yii\db\ActiveQuery */ public function getOrganization() { return $this->hasOne(Organizations::className(), ['id' => 'organization_id']); }