common/models/search/MediaComment.php
/**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     * @param int|null $mediaId
     * @return ActiveDataProvider
     */
Creates data provider instance with search query applied
@param array $params
@param int|null $mediaId
@return ActiveDataProvider
Creates data provider instance with search query applied @param array $params @param int|null $mediaId @return ActiveDataProvider
public function search($params, $mediaId = null)
    {
        $query = MediaCommentModel::find();
        $query->innerJoinWith([
            'commentMedia' => function ($query) {
                return $query->from(['media' => Media::tableName()]);
            },
        ])->from(['mediaComment' => static::tableName()]);
        if ($mediaId) {
            $query->andWhere(['media.id' => $mediaId]);
        }
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'sort' => [
                'defaultOrder' => [
                    'id' => SORT_DESC,
                ],
            ],
        ]);
        $this->load($params);
        if (!$this->validate()) {
            return $dataProvider;
        }
        $query->andFilterWhere([
            'id' => $this->id,
            'media_id' => $this->media_id,
            'parent' => $this->parent,
            'user_id' => $this->user_id,
        ]);
        $query->andFilterWhere(['like', 'mediaComment.author', $this->author])
            ->andFilterWhere(['like', 'email', $this->email])
            ->andFilterWhere(['like', 'url', $this->url])
            ->andFilterWhere(['like', 'ip', $this->ip])
            ->andFilterWhere(['like', 'mediaComment.content', $this->content])
            ->andFilterWhere(['like', 'status', $this->status])
            ->andFilterWhere(['like', 'agent', $this->agent])
            ->andFilterWhere(['like', 'mediaComment.date', $this->date])
            ->andFilterWhere(['like', 'media.title', $this->media_title]);
        return $dataProvider;
    }
public function search ( $ params , $ mediaId = null ) { $ query = MediaCommentModel :: find ( ) ; $ query -> innerJoinWith ( [ 'commentMedia' => function ( $ query ) { return $ query -> from ( [ 'media' => Media :: tableName ( ) ] ) ; } , ] ) -> from ( [ 'mediaComment' => static :: tableName ( ) ] ) ; if ( $ mediaId ) { $ query -> andWhere ( [ 'media.id' => $ mediaId ] ) ; } $ dataProvider = new ActiveDataProvider ( [ 'query' => $ query , 'sort' => [ 'defaultOrder' => [ 'id' => SORT_DESC , ] , ] , ] ) ; $ this -> load ( $ params ) ; if ( ! $ this -> validate ( ) ) { return $ dataProvider ; } $ query -> andFilterWhere ( [ 'id' => $ this -> id , 'media_id' => $ this -> media_id , 'parent' => $ this -> parent , 'user_id' => $ this -> user_id , ] ) ; $ query -> andFilterWhere ( [ 'like' , 'mediaComment.author' , $ this -> author ] ) -> andFilterWhere ( [ 'like' , 'email' , $ this -> email ] ) -> andFilterWhere ( [ 'like' , 'url' , $ this -> url ] ) -> andFilterWhere ( [ 'like' , 'ip' , $ this -> ip ] ) -> andFilterWhere ( [ 'like' , 'mediaComment.content' , $ this -> content ] ) -> andFilterWhere ( [ 'like' , 'status' , $ this -> status ] ) -> andFilterWhere ( [ 'like' , 'agent' , $ this -> agent ] ) -> andFilterWhere ( [ 'like' , 'mediaComment.date' , $ this -> date ] ) -> andFilterWhere ( [ 'like' , 'media.title' , $ this -> media_title ] ) ; return $ dataProvider ; }
Creates data provider instance with search query applied
 @param array $params
 @param int|null $mediaId
 @return ActiveDataProvider
Creates data provider instance with search query applied @param array $params @param int|null $mediaId @return ActiveDataProvider
/* @var $query \yii\db\ActiveQuery */