/**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = Tuition::find();

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        $query->andFilterWhere([
            'tuitionfee_id' => $this->tuitionfee_id,
            'tuitionfee_scholar_id' => $this->tuitionfee_scholar_id,
            'tuitionfee_amount' => $this->tuitionfee_amount,
            'tuitionfee_dateOfEnrollment' => $this->tuitionfee_dateOfEnrollment,
            'tuitionfee_dateOfPayment' => $this->tuitionfee_dateOfPayment,
        ]);

        $query->andFilterWhere(['like', 'tuitionfee_scholar_lastName', $this->tuitionfee_scholar_lastName])
            ->andFilterWhere(['like', 'tuitionfee_scholar_firstName', $this->tuitionfee_scholar_firstName])
            ->andFilterWhere(['like', 'tuitionfee_scholar_middleName', $this->tuitionfee_scholar_middleName])
            ->andFilterWhere(['like', 'tuitionfee_paidStatus', $this->tuitionfee_paidStatus])
            ->andFilterWhere(['like', 'tuitionfee_registrationForm', $this->tuitionfee_registrationForm]);

        return $dataProvider;
    }
    public function actionIndex()
    {
		$grades = Grades::find()->all();
		$schools = Schools::find()->all();
		$users = User::find()->all();
		$scholars = Scholars::find()->all();
		$tuitions = Tuition::find()->all();
		return $this->render('index',array('users'=>$users,'scholars'=>$scholars,'schools'=>$schools,'grades'=>$grades,'tuition'=>$tuitions));
    }
    /**
     * Updates an existing Tuition model.
     * If update is successful, the browser will be redirected to the 'view' page.
     * @param integer $id
     * @return mixed
     */
    public function actionUpdate()
    {
		$username=Yii::$app->user->identity->username;
		$users= User::find()->all();
		$grades = Grades::find()->all();
		$tuitions = Tuition::find()->all();
		$model = new Grades();
		foreach($users as $user){
			foreach($tuitions as $tuition){
				if($user->username==$username&&$user->id==$tuition->tuitionfee_scholar_id){
					$id=$tuition->tuitionfee_scholar_id;
					$model = $this->findModel($id);
					if ($model->load(Yii::$app->request->post()) && $model->save()) {
					return $this->redirect(['view', 'id' => $model->grade_id]);
					} else {
					return $this->render('update', [
					'model' => $model,
					]);
					}
				}
			}
		}
    }