<commit_before><?php

class Category extends Elegant
{
    use SoftDeletingTrait;
    protected $dates = ['deleted_at'];
    protected $table = 'categories';

    /**
    * Category validation rules
    */
    public $rules = array(
        'user_id' => 'numeric',
        'name'   => 'required|alpha_space|min:3|max:255|unique:categories,name,{id}',
        'category_type'   => 'required',
    );

    public function has_models()
    {
        return $this->hasMany('Model', 'category_id')->count();
    }

    public function assetscount()
    {
        return $this->hasManyThrough('Asset', 'Model')->count();
    }
    
    public function accessoriescount()
    {
        return $this->hasMany('Accessory')->count();
    }
    
    public function accessories()
    {
        return $this->hasMany('Asset');
    }


    public function assets()
    {
        return $this->hasManyThrough('Asset', 'Model');
    }

    public function models()
    {
        return $this->hasMany('Model', 'category_id');
    }
    
    public function getEula() { 
	      
	    $Parsedown = new Parsedown();
        
	    if ($this->eula_text) {
		    return $Parsedown->text(e($this->eula_text));
	    } elseif ((Setting::getSettings()->default_eula_text) && ($this->use_default_eula=='1')) {
		    return $Parsedown->text(e(Setting::getSettings()->default_eula_text));
	    } else {
		    return null;
	    } 
	    
    }

    
    
}<commit_msg>Added a scope to the Category model to pull back only categories that required acceptance<commit_after><?php

class Category extends Elegant
{
    use SoftDeletingTrait;
    protected $dates = ['deleted_at'];
    protected $table = 'categories';

    /**
    * Category validation rules
    */
    public $rules = array(
        'user_id' => 'numeric',
        'name'   => 'required|alpha_space|min:3|max:255|unique:categories,name,{id}',
        'category_type'   => 'required',
    );

    public function has_models()
    {
        return $this->hasMany('Model', 'category_id')->count();
    }

    public function assetscount()
    {
        return $this->hasManyThrough('Asset', 'Model')->count();
    }

    public function accessoriescount()
    {
        return $this->hasMany('Accessory')->count();
    }

    public function accessories()
    {
        return $this->hasMany('Asset');
    }


    public function assets()
    {
        return $this->hasManyThrough('Asset', 'Model');
    }

    public function models()
    {
        return $this->hasMany('Model', 'category_id');
    }

    public function getEula() {

	    $Parsedown = new Parsedown();

	    if ($this->eula_text) {
		    return $Parsedown->text(e($this->eula_text));
	    } elseif ((Setting::getSettings()->default_eula_text) && ($this->use_default_eula=='1')) {
		    return $Parsedown->text(e(Setting::getSettings()->default_eula_text));
	    } else {
		    return null;
	    }

    }

    /**
     * scopeRequiresAcceptance
     *
     * @param $query
     *
     * @return mixed
     * @author  <NAME> <<EMAIL>>
     * @version v1.0
     */
    public function scopeRequiresAcceptance( $query )
    {

        return $query->where( 'require_acceptance', '=', true );
    }

}
{'fraction_non_alphanumeric': 0.15447154471544716, 'fraction_numerical': 0.00375234521575985, 'mean_word_length': 2.5231277533039647, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 45, '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': '3589416', 'n_tokens_mistral': 1020, 'n_tokens_neox': 967, 'n_words': 186}