<?php

namespace backend\models;

use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\models\Frapl011a;

/**
 * Frapl011aSearch represents the model behind the search form of `backend\models\Frapl011a`.
 */
class Frapl011aSearch extends Frapl011a
{
    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['FRAPL01_UUID', 'FRAPL01_1A_UUID', 'FRAPL01_1A_NAMA', 'FRAPL01_1A_TGL_LAHIR', 'FRAPL01_1A_TPT_LAHIR', 'FRAPL01_1A_JK', 'FRAPL01_1A_KEBANGSAAN', 'FRAPL01_1A_ALAMAT', 'FRAPL01_1A_POS', 'FRAPL01_1A_TEL_RUMAH', 'FRAPL01_1A_TEL_KANTOR', 'FRAPL01_1A_HP', 'FRAPL01_1A_EMAIL', 'FRAPL01_1A_JENJANG', 'FRAPL01_1A_JURUSAN', 'FRAPL01_1A_KAMPUS', 'FRAPL01_1A_THN_LULUS', 'USERNAME'], 'safe'],
            [['FRAPL01_1A_NIK', 'CREATED'], 'integer'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function scenarios()
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     * @param string|null $formName Form name to be used into `->load()` method.
     *
     * @return ActiveDataProvider
     */
    public function search($params, $formName = null)
    {
        $query = Frapl011a::find();

        // add conditions that should always apply here

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

        $this->load($params, $formName);

        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;
        }

        // grid filtering conditions
        $query->andFilterWhere([
            'FRAPL01_1A_NIK' => $this->FRAPL01_1A_NIK,
            'FRAPL01_1A_TGL_LAHIR' => $this->FRAPL01_1A_TGL_LAHIR,
            'FRAPL01_1A_THN_LULUS' => $this->FRAPL01_1A_THN_LULUS,
            'CREATED' => $this->CREATED,
        ]);

        $query->andFilterWhere(['like', 'FRAPL01_UUID', $this->FRAPL01_UUID])
            ->andFilterWhere(['like', 'FRAPL01_1A_UUID', $this->FRAPL01_1A_UUID])
            ->andFilterWhere(['like', 'FRAPL01_1A_NAMA', $this->FRAPL01_1A_NAMA])
            ->andFilterWhere(['like', 'FRAPL01_1A_TPT_LAHIR', $this->FRAPL01_1A_TPT_LAHIR])
            ->andFilterWhere(['like', 'FRAPL01_1A_JK', $this->FRAPL01_1A_JK])
            ->andFilterWhere(['like', 'FRAPL01_1A_KEBANGSAAN', $this->FRAPL01_1A_KEBANGSAAN])
            ->andFilterWhere(['like', 'FRAPL01_1A_ALAMAT', $this->FRAPL01_1A_ALAMAT])
            ->andFilterWhere(['like', 'FRAPL01_1A_POS', $this->FRAPL01_1A_POS])
            ->andFilterWhere(['like', 'FRAPL01_1A_TEL_RUMAH', $this->FRAPL01_1A_TEL_RUMAH])
            ->andFilterWhere(['like', 'FRAPL01_1A_TEL_KANTOR', $this->FRAPL01_1A_TEL_KANTOR])
            ->andFilterWhere(['like', 'FRAPL01_1A_HP', $this->FRAPL01_1A_HP])
            ->andFilterWhere(['like', 'FRAPL01_1A_EMAIL', $this->FRAPL01_1A_EMAIL])
            ->andFilterWhere(['like', 'FRAPL01_1A_JENJANG', $this->FRAPL01_1A_JENJANG])
            ->andFilterWhere(['like', 'FRAPL01_1A_JURUSAN', $this->FRAPL01_1A_JURUSAN])
            ->andFilterWhere(['like', 'FRAPL01_1A_KAMPUS', $this->FRAPL01_1A_KAMPUS])
            ->andFilterWhere(['like', 'USERNAME', $this->USERNAME]);

        return $dataProvider;
    }
}
