<commit_before><?php

namespace app\models;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use app\models\PregnacyCdssSymptoms;

/**
 * PregnacyCdssSymptomsSearch represents the model behind the search form about `app\models\PregnacyCdssSymptoms`.
 */
class PregnacyCdssSymptomsSearch extends PregnacyCdssSymptoms
{
    //public $symptCategory;
    
    public function attributes()
    {
    // add related fields to searchable attributes
    return array_merge(parent::attributes(), ['symptCategory.cat_name']);
    }
    
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id', 'id_order', 'id_category', 'is_multi', 'is_selected'], 'integer'],
            [['symp_name', 'symp_notes', 'symptCategory.cat_name'], '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 = PregnacyCdssSymptoms::find();
        
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        // join with relation `symptCategory` that is a relation to the table `form_pregnacycdss_sympt_category`
        // and set the table alias to be `symptCategory` (upd: table name get from model class by method)
        $query->joinWith(['symptCategory' => function($query) { $query->from(['symptCategory' => PregnacyCdssSymptCategory::tableName()]); }]);
        
        // enable sorting for the related column
        $dataProvider->sort->attributes['symptCategory.cat_name'] = [
            'asc' => ['symptCategory.cat_name' => SORT_ASC],
            'desc' => ['symptCategory.cat_name' => SORT_DESC],
        ];

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        $query->andFilterWhere([
            'id' => $this->id,
            'id_order' => $this->id_order,
            'id_category' => $this->id_category,
            'is_multi' => $this->is_multi,
            'is_selected' => $this->is_selected,
        ]);

        $query->andFilterWhere(['like', 'symp_name', $this->symp_name])
            ->andFilterWhere(['like', 'symp_notes', $this->symp_notes]);

        return $dataProvider;
    }
}<commit_msg>add filter to the "symptom category" column<commit_after><?php

namespace app\models;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use app\models\PregnacyCdssSymptoms;

/**
 * PregnacyCdssSymptomsSearch represents the model behind the search form about `app\models\PregnacyCdssSymptoms`.
 */
class PregnacyCdssSymptomsSearch extends PregnacyCdssSymptoms
{
    //public $symptCategory;
    
    public function attributes()
    {
    // add related fields to searchable attributes
    return array_merge(parent::attributes(), ['symptCategory.cat_name']);
    }
    
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id', 'id_order', 'id_category', 'is_multi', 'is_selected'], 'integer'],
            [['symp_name', 'symp_notes', 'symptCategory.cat_name'], '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 = PregnacyCdssSymptoms::find();
        
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        // join with relation `symptCategory` that is a relation to the table `form_pregnacycdss_sympt_category`
        // and set the table alias to be `symptCategory` (upd: table name get from model class by method)
        $query->joinWith(['symptCategory' => function($query) { $query->from(['symptCategory' => PregnacyCdssSymptCategory::tableName()]); }]);
        
        // enable sorting for the related column
        $dataProvider->sort->attributes['symptCategory.cat_name'] = [
            'asc' => ['symptCategory.cat_name' => SORT_ASC],
            'desc' => ['symptCategory.cat_name' => SORT_DESC],
        ];

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        $query->andFilterWhere([
            'id' => $this->id,
            'id_order' => $this->id_order,
            'id_category' => $this->id_category,
            'is_multi' => $this->is_multi,
            'is_selected' => $this->is_selected,
        ]);

        $query->andFilterWhere(['like', 'symptCategory.cat_name', $this->getAttribute('symptCategory.cat_name')]);
        
        $query->andFilterWhere(['like', 'symp_name', $this->symp_name])
            ->andFilterWhere(['like', 'symp_notes', $this->symp_notes]);

        return $dataProvider;
    }
}
{'fraction_non_alphanumeric': 0.13725847612103537, 'fraction_numerical': 0.0007291286912139992, 'mean_word_length': 2.4487743557511, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3089192', 'n_tokens_mistral': 1643, 'n_tokens_neox': 1600, 'n_words': 361}