/** * Lists all Grades models. * @return mixed */ public function actionIndex() { $username = Yii::$app->user->identity->username; $users = User::find()->all(); $scholars = Scholar::find()->all(); $model = new Tuition(); foreach ($users as $user) { foreach ($scholars as $scholar) { if ($user->username == $username && $user->id == $scholar->scholar_user_id) { $model->scholar_scholar_id = $scholar->scholar_id; $searchModel = new TuitionSearch($model); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); } } } }
<?php use yii\helpers\Html; use kartik\grid\GridView; use kartik\export\ExportMenu; use common\models\TuitionSearch; $gridColumns = [['class' => 'kartik\\grid\\ExpandRowColumn', 'value' => function ($model, $key, $index, $column) { return GridView::ROW_COLLAPSED; }, 'detail' => function ($model, $key, $index, $column) { $searchModel = new TuitionSearch(); $searchModel->scholar_school_school_id = $model->school_id; $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return Yii::$app->controller->renderPartial('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }], 'school_name', 'school_area']; /* @var $this yii\web\View */ /* @var $searchModel common\models\SchoolSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'Schools'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="school-index"> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <h1><?php echo Html::encode($this->title); ?> </h1> <?php $exportedValues = [['class' => 'kartik\\grid\\SerialColumn'], 'school_id', 'school_name', 'school_area', 'school_address', 'school_contact_emails:email', 'school_contact_numbers', 'school_vendor_code', ['class' => 'kartik\\grid\\ActionColumn']];
public function actionIndex2() { $searchModel = new TuitionSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index2', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }