<commit_before><?php

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

    /**
    * Category validation rules
    */
    public $rules = array(
        'name'   => 'required|alpha_space|min:3|max:255|unique:accessories,name,{id}',
        'category_id'   	=> 'required|integer',
        'qty'   	=> 'required|integer|min:1',
    );

    public function category()
    {
        return $this->belongsTo('Category', 'category_id');
    }

    /**
    * Get action logs for this accessory
    */
     public function assetlog()
    {
        return $this->hasMany('Actionlog','accessory_id')->where('asset_type','=','accessory')->orderBy('created_at', 'desc')->withTrashed();
    }
    
    
    public function users()
    {
        return $this->belongsToMany('User', 'users', 'id')->withTrashed();
    }
    
    
}<commit_msg>Methods to extend the category EULA to the accessory<commit_after><?php

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

    /**
    * Category validation rules
    */
    public $rules = array(
        'name'   => 'required|alpha_space|min:3|max:255',
        'category_id'   	=> 'required|integer',
        'qty'   	=> 'required|integer|min:1',
    );

    public function category()
    {
        return $this->belongsTo('Category', 'category_id');
    }

    /**
    * Get action logs for this accessory
    */
     public function assetlog()
    {
        return $this->hasMany('Actionlog','accessory_id')->where('asset_type','=','accessory')->orderBy('created_at', 'desc')->withTrashed();
    }
    
    
    public function users()
    {
        return $this->belongsToMany('User', 'accessories_users', 'user_id')->withTrashed();
    }
    
    
    public function requireAcceptance() {    
	    return $this->category->require_acceptance;
    }
    
    public function getEula() { 
	      
	    $Parsedown = new Parsedown();
        
	    if ($this->category->eula_text) {
		    return $Parsedown->text(e($this->category->eula_text));
	    } elseif (Setting::getSettings()->default_eula_text) {
		    return $Parsedown->text(e(Setting::getSettings()->default_eula_text));
	    } else {
		    return null;
	    } 
	    
    }

    
}
{'fraction_non_alphanumeric': 0.1548277328796257, 'fraction_numerical': 0.004253509145044662, 'mean_word_length': 2.675, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, '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': '2231380', 'n_tokens_mistral': 752, 'n_tokens_neox': 725, 'n_words': 130}