<?php

namespace PortalPeople\oauth2\models;

class OauthScopesSearch extends OauthScope
{
    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['scope', 'is_default'], 'safe'],
        ];
    }

    public function search($params){
        $query = OauthScope::find();
        $dataProvider = new \yii\data\ActiveDataProvider([
            'query' => $query,
        ]);
        $this->load($params);
        if (!$this->validate()) {
            return $dataProvider;
        }
        $query->andFilterWhere(['like', 'scope', $this->scope]);
        $query->andFilterWhere(['is_default' => $this->is_default]);
        return $dataProvider;
    }
}