Your IP : 216.73.216.79


Current Path : /var/www/html/brspace/backend/modules/contentDirectory/models/
Upload File :
Current File : /var/www/html/brspace/backend/modules/contentDirectory/models/ContentDirectorySearch.php

<?php

namespace backend\modules\contentDirectory\models;

use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\contentDirectory\models\ContentDirectory;

/**
 * ContentDirectorySearch represents the model behind the search form of `backend\modules\contentDirectory\models\ContentDirectory`.
 */
class ContentDirectorySearch extends ContentDirectory {

    /**
     * {@inheritdoc}
     */
    public function rules() {
        return [
            [['created_at', 'updated_at',
               
                'employee_phone',
                'employee_email','employee_name','employee_dept',
                'job_title','job_grade',], 'safe'],
            [['created_by', 'updated_by','sorting'], '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
     *
     * @return ActiveDataProvider
     */
    public function search($params) {
        $query = ContentDirectory::find();
$this->load($params);
        // add conditions that should always apply here
        $status_pagination = 10;
        if (!empty($this->employee_dept))
            $status_pagination = false;
        
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'pagination' => ['pageSize' => 10,],
            'sort' => ['defaultOrder' => ['sorting' => SORT_ASC]],
        ]);

        

        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(['=', 'employee_dept', $this->employee_dept]);
        $query->andFilterWhere(['LIKE', 'employee_name', $this->employee_name]);
        $query->andFilterWhere(['=', 'sorting', $this->sorting]);
 
        return $dataProvider;
    }

}