You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

82 lines
2.3 KiB

  1. <?php
  2. namespace common\models;
  3. use Yii;
  4. use yii\base\Model;
  5. use yii\data\ActiveDataProvider;
  6. use common\models\BaseRole;
  7. /**
  8. * searchRole represents the model behind the search form about `common\models\BaseRole`.
  9. */
  10. class searchRole extends BaseRole
  11. {
  12. /**
  13. * @inheritdoc
  14. */
  15. public function rules()
  16. {
  17. return [
  18. [['ID', 'PARENT_MENU_ID', 'CANCEL_FLAG', 'CREATE_USER_ID', 'UPDATE_USER_ID', 'SEQ'], 'integer'],
  19. [['MENU_TITLE', 'ROLE_NAME', 'MENU_ICON', 'CREATE_TIME', 'UPDATE_TIME', 'TARGET', 'NOTE'], 'safe'],
  20. ];
  21. }
  22. /**
  23. * @inheritdoc
  24. */
  25. public function scenarios()
  26. {
  27. // bypass scenarios() implementation in the parent class
  28. return Model::scenarios();
  29. }
  30. /**
  31. * Creates data provider instance with search query applied
  32. *
  33. * @param array $params
  34. *
  35. * @return ActiveDataProvider
  36. */
  37. public function search($params)
  38. {
  39. $query = BaseRole::find();
  40. // add conditions that should always apply here
  41. $dataProvider = new ActiveDataProvider([
  42. 'query' => $query,
  43. ]);
  44. $this->load($params);
  45. if (!$this->validate()) {
  46. // uncomment the following line if you do not want to return any records when validation fails
  47. // $query->where('0=1');
  48. return $dataProvider;
  49. }
  50. // grid filtering conditions
  51. $query->andFilterWhere([
  52. 'ID' => $this->ID,
  53. 'ROLE_SYS' => $this->ROLE_SYS,
  54. 'PARENT_MENU_ID' => $this->PARENT_MENU_ID,
  55. 'CANCEL_FLAG' => $this->CANCEL_FLAG,
  56. 'CREATE_USER_ID' => $this->CREATE_USER_ID,
  57. 'UPDATE_USER_ID' => $this->UPDATE_USER_ID,
  58. 'SEQ' => $this->SEQ,
  59. ]);
  60. $query->andFilterWhere(['like', 'MENU_TITLE', $this->MENU_TITLE])
  61. ->andFilterWhere(['like', 'ROLE_NAME', $this->ROLE_NAME])
  62. ->andFilterWhere(['like', 'MENU_ICON', $this->MENU_ICON])
  63. ->andFilterWhere(['like', 'CREATE_TIME', $this->CREATE_TIME])
  64. ->andFilterWhere(['like', 'UPDATE_TIME', $this->UPDATE_TIME])
  65. ->andFilterWhere(['like', 'TARGET', $this->TARGET])
  66. ->andFilterWhere(['like', 'NOTE', $this->NOTE]);
  67. return $dataProvider;
  68. }
  69. }