<commit_before><?php

namespace worstinme\zoo\models;

use Yii;
use yii\helpers\Json;

class Applications extends \yii\db\ActiveRecord
{
    private $catlist;
    private $templatesConfig;

    public static function tableName()
    {
        return '{{%zoo_applications}}';
    }

    public function afterFind()
    {
        $this->params = !empty($this->params) ? Json::decode($this->params) : [];
        return parent::afterFind();
    }

    public function beforeSave($insert) {
        if (parent::beforeSave($insert)) {

            $this->params = Json::encode($this->params);
            
            return true;
        }
        else return false;
    }

    public function afterSave($insert, $changedAttributes)
    {   
        $this->params = Json::decode($this->params);
        return parent::afterSave($insert, $changedAttributes);
    } 

    public function getParentCategories() {
        return $this->hasMany(Categories::className(), ['app_id' => 'id'])->where(['parent_id'=>0,'state'=>1])->orderBy('sort ASC');
    }

    public function getCategories() {
        return $this->hasMany(Categories::className(), ['app_id' => 'id'])->where(['state'=>1])->orderBy('sort ASC')->inverseOf('app');
    }

    public function getItems() {
        return $this->hasMany(Items::className(), ['app_id' => 'id'])->inverseOf('app');<commit_msg>query update<commit_after><?php

namespace worstinme\zoo\models;

use Yii;
use yii\helpers\Json;

class Applications extends \yii\db\ActiveRecord
{
    private $catlist;
    private $templatesConfig;

    public static function tableName()
    {
        return '{{%zoo_applications}}';
    }

    public function afterFind()
    {
        $this->params = !empty($this->params) ? Json::decode($this->params) : [];
        return parent::afterFind();
    }

    public function beforeSave($insert) {
        if (parent::beforeSave($insert)) {

            $this->params = Json::encode($this->params);
            
            return true;
        }
        else return false;
    }

    public function afterSave($insert, $changedAttributes)
    {   
        $this->params = Json::decode($this->params);
        return parent::afterSave($insert, $changedAttributes);
    } 

    public function getParentCategories() {
        return $this->hasMany(Categories::className(), ['app_id' => 'id'])->where(['parent_id'=>0,'state'=>1])->orderBy('sort ASC');
    }

    public function getCategories() {
        return $this->hasMany(Categories::className(), ['app_id' => 'id'])->where(['state'=>1])->orderBy('sort ASC')->inverseOf('app');
    }

    public function getItems() {
        return $this->hasMany(Items::className(), ['app_id' => 'id'])->inverseOf('app')->where([Items::tablename().'.state'=>1]);
{'fraction_non_alphanumeric': 0.17608695652173914, 'fraction_numerical': 0.002536231884057971, 'mean_word_length': 3.1270553064275037, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 49, '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': '3707508', 'n_tokens_mistral': 821, 'n_tokens_neox': 788, 'n_words': 146}