예제 #1
0
 /**
  * Creates data provider instance with search query applied
  * @param array $params
  * @return ActiveDataProvider
  */
 public function singleSearch($params, $query = null)
 {
     $this->load($params);
     $query = isset($query) ? $query : Tenant::find();
     $query->andFilterWhere(['or', ['like', 'name', $this->searchField]]);
     return $dataProvider = new ActiveDataProvider(['query' => $query]);
 }
 /**
  * @return mixed
  */
 public function actionChangeTenant()
 {
     $model = new ChangeTenantForm();
     $tenantSelectProvider = ArrayHelper::map(Tenant::find()->select(['{{%tenant}}.id', '{{%tenant}}.name'])->byLoginUser()->notLoginTenant()->orderBy('{{%tenant}}.name')->asArray()->all(), 'id', 'name');
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->changeTenant()) {
             Yii::$app->getSession()->setFlash('success', 'You have successfully change tenant!');
             return $this->goBack();
         }
         Yii::$app->getSession()->setFlash('error', 'You have failed to change tenant!');
         return $this->goBack();
     }
     return $this->renderAjax('change-tenant-form', ['model' => $model, 'tenantSelectProvider' => $tenantSelectProvider]);
 }
예제 #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTenant()
 {
     return $this->hasOne(Tenant::className(), ['id' => 'tenant_id']);
 }
예제 #4
0
 /**
  * Renders the widget.
  */
 public function run()
 {
     Portlet::begin(['title' => $this->title, 'subtitle' => $this->subtitle, 'buttons' => [Search::widget(['searchModel' => $this->searchModel]), ModalButton::widget(['buttonLabel' => Html::tag('i', '', ['class' => 'fa fa-plus']), 'url' => Url::to(['tenant/ajax-create', 'pjaxId' => 'list-pjax']), 'tooltipTitle' => 'New Tenant', 'name' => 'new-tenant-button'])]]);
     echo GridView::widget(['id' => 'gridview-tenant', 'dataProvider' => $this->dataProvider, 'columns' => Tenant::column()->raw(['name'])->actions('{view} {ajax-update} {ajax-delete}')->all(), 'options' => ['class' => 'table-scrollable table-scrollable-borderless'], 'tableOptions' => ['class' => 'table table-hover table-light'], 'headerRowOptions' => ['class' => 'uppercase'], 'summary' => '']);
     Portlet::end();
 }