/**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = ApprovedGrades::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([
            'grade_id' => $this->grade_id,
            'grade_schoolYear' => $this->grade_schoolYear,
            'grade_Term' => $this->grade_Term,
            'grade_scholar_id' => $this->grade_scholar_id,
            'grade_units' => $this->grade_units,
            'grade_value' => $this->grade_value,
            'School_id' => $this->School_id,
        ]);

        $query->andFilterWhere(['like', 'grade_subject', $this->grade_subject])
            ->andFilterWhere(['like', 'approval_status', $this->approval_status])
            ->andFilterWhere(['like', 'approved_by', $this->approved_by])
            ->andFilterWhere(['like', 'approved_remark', $this->approved_remark]);

        return $dataProvider;
    }
 /**
  * Finds the ApprovedGrades model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return ApprovedGrades the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ApprovedGrades::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }