{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii2-gii/issues/61","labels_url":"https://api.github.com/repos/yiisoft/yii2-gii/issues/61/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2-gii/issues/61/comments","events_url":"https://api.github.com/repos/yiisoft/yii2-gii/issues/61/events","html_url":"https://github.com/yiisoft/yii2-gii/pull/61","id":90604617,"number":61,"title":"Updates for Search-Form Model.","user":{"login":"githubjeka","id":874234,"avatar_url":"https://avatars.githubusercontent.com/u/874234?v=3","gravatar_id":"","url":"https://api.github.com/users/githubjeka","html_url":"https://github.com/githubjeka","followers_url":"https://api.github.com/users/githubjeka/followers","following_url":"https://api.github.com/users/githubjeka/following{/other_user}","gists_url":"https://api.github.com/users/githubjeka/gists{/gist_id}","starred_url":"https://api.github.com/users/githubjeka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/githubjeka/subscriptions","organizations_url":"https://api.github.com/users/githubjeka/orgs","repos_url":"https://api.github.com/users/githubjeka/repos","events_url":"https://api.github.com/users/githubjeka/events{/privacy}","received_events_url":"https://api.github.com/users/githubjeka/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-06-24T08:17:23Z","updated_at":"2015-06-24T09:14:59Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/yiisoft/yii2-gii/pulls/61","html_url":"https://github.com/yiisoft/yii2-gii/pull/61","diff_url":"https://github.com/yiisoft/yii2-gii/pull/61.diff","patch_url":"https://github.com/yiisoft/yii2-gii/pull/61.patch"},"body":"Now search model will not inherit Active Record model.\r\nThis allows you to get rid of the duct tape method `scenarios()`.\r\nAnd teaches the right way of using models and active records.\r\n\r\nGenerated example for `common\\models\\User`.\r\n```php\r\n<?php\r\n\r\nnamespace backend\\models; \r\n\r\nuse Yii; \r\nuse yii\\base\\Model; \r\nuse yii\\data\\ActiveDataProvider; \r\nuse common\\models\\User; \r\n\r\n/** \r\n * UserSearch represents the model behind the search form about `common\\models\\User`. \r\n */ \r\nclass UserSearch extends Model \r\n{ \r\n    /** \r\n    * @var integer \r\n    */ \r\n    public $id; \r\n    /** \r\n    * @var string \r\n    */ \r\n    public $username; \r\n    /** \r\n    * @var string \r\n    */ \r\n    public $auth_key; \r\n    /** \r\n    * @var string \r\n    */ \r\n    public $password_hash; \r\n    /** \r\n    * @var string \r\n    */ \r\n    public $password_reset_token; \r\n    /** \r\n    * @var string \r\n    */ \r\n    public $email; \r\n    /** \r\n    * @var integer \r\n    */ \r\n    public $status; \r\n    /** \r\n    * @var integer \r\n    */ \r\n    public $created_at; \r\n    /** \r\n    * @var integer \r\n    */ \r\n    public $updated_at; \r\n    /** \r\n    * @var string \r\n    */ \r\n    public $description; \r\n    /** \r\n    * @var integer \r\n    */ \r\n    public $signin_at;    \r\n    /** \r\n    * @var integer \r\n    */ \r\n    public $activity_at; \r\n     \r\n\r\n    /** \r\n     * @inheritdoc \r\n     */ \r\n    public function rules() \r\n    { \r\n        return [ \r\n            [['id', 'status', 'created_at', 'updated_at', 'signin_at', 'activity_at'], 'integer'],\r\n            [['username', 'auth_key', 'password_hash', 'password_reset_token', 'email', 'description'], 'safe'],\r\n        ]; \r\n    } \r\n\r\n    /** \r\n     * Creates data provider instance with search query applied \r\n     * \r\n     * @param array $params \r\n     * \r\n     * @return ActiveDataProvider \r\n     */ \r\n    public function search($params) \r\n    { \r\n        $query = User::find(); \r\n\r\n        $dataProvider = new ActiveDataProvider([ \r\n            'query' => $query, \r\n        ]); \r\n\r\n        $this->load($params); \r\n\r\n        if (!$this->validate()) { \r\n            // uncomment the following line if you do not want to return any records when validation fails\r\n            // $query->where('0=1'); \r\n            return $dataProvider; \r\n        } \r\n\r\n        $query->andFilterWhere([\r\n            'id' => $this->id,\r\n            'status' => $this->status,\r\n            'created_at' => $this->created_at,\r\n            'updated_at' => $this->updated_at,\r\n            'signin_at' => $this->signin_at,\r\n            'activity_at' => $this->activity_at,\r\n        ]);\r\n\r\n        $query->andFilterWhere(['like', 'username', $this->username])\r\n            ->andFilterWhere(['like', 'auth_key', $this->auth_key])\r\n            ->andFilterWhere(['like', 'password_hash', $this->password_hash])\r\n            ->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token])\r\n            ->andFilterWhere(['like', 'email', $this->email])\r\n            ->andFilterWhere(['like', 'description', $this->description])\r\n\r\n        return $dataProvider; \r\n    } \r\n} \r\n```"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii2-gii/issues/comments/114798212","html_url":"https://github.com/yiisoft/yii2-gii/pull/61#issuecomment-114798212","issue_url":"https://api.github.com/repos/yiisoft/yii2-gii/issues/61","id":114798212,"user":{"login":"LAV45","id":675367,"avatar_url":"https://avatars.githubusercontent.com/u/675367?v=3","gravatar_id":"","url":"https://api.github.com/users/LAV45","html_url":"https://github.com/LAV45","followers_url":"https://api.github.com/users/LAV45/followers","following_url":"https://api.github.com/users/LAV45/following{/other_user}","gists_url":"https://api.github.com/users/LAV45/gists{/gist_id}","starred_url":"https://api.github.com/users/LAV45/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LAV45/subscriptions","organizations_url":"https://api.github.com/users/LAV45/orgs","repos_url":"https://api.github.com/users/LAV45/repos","events_url":"https://api.github.com/users/LAV45/events{/privacy}","received_events_url":"https://api.github.com/users/LAV45/received_events","type":"User","site_admin":false},"created_at":"2015-06-24T09:14:59Z","updated_at":"2015-06-24T09:14:59Z","body":"Already offered, it is useless\r\nhttps://github.com/yiisoft/yii2-gii/pull/51"}}