Your IP : 216.73.216.124


Current Path : /var/www/html/chatbot/backend/models/
Upload File :
Current File : /var/www/html/chatbot/backend/models/MemoSearch.php

<?php

namespace backend\models;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\models\Memo;


class MemoSearch extends Memo
{
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id'], 'integer'],
            [['memo_cat', 'memo_ty', 'memo_to', 'memo_from', 'msg', 'memo_dt', 'status', 'param', 'created_by', 'created_at', 'updated_by', 'updated_at'], 'safe'],
        ];
    }

    /**
     * @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 = Memo::find();

        // add conditions that should always apply here

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]],
        ]);

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

        // grid filtering conditions
        $query->where(['memo_to' => Yii::$app->user->identity->staff->id,]);
//        
//        $query->andFilterWhere([
//            'id' => $this->id,
//            'memo_dt' => $this->memo_dt,
//            'created_at' => $this->created_at,
//            'updated_at' => $this->updated_at,
//        ]);

//        $query->andFilterWhere(['like', 'memo_cat', $this->memo_cat])
//            ->andFilterWhere(['like', 'memo_ty', $this->memo_ty])
//            ->andFilterWhere(['like', 'memo_to', $this->memo_to])
//            ->andFilterWhere(['like', 'memo_from', $this->memo_from]);
            

        return $dataProvider;
    }
}