<commit_before><?php namespace Tiipiik\Catalog\Models;

use Model;
use Cms\Classes\Page as CmsPage;
use Cms\Classes\Theme;

/**
 * Category Model
 */
class Category extends Model
{
    use \October\Rain\Database\Traits\NestedTree;
    use \October\Rain\Database\Traits\Validation;

    /**
     * @var string The database table used by the model.
     */
    public $table = 'tiipiik_catalog_categories';

    /**
     * Validation rules
     */
    public $rules = [
        'name' => 'required|unique:tiipiik_catalog_categories',
        'slug' => 'required',
    ];

    /**
     * @var array Translatable fields
     */
    public $translatable = ['name', 'description'];
    
    /**
     * @var array Guarded fields
     */
    protected $guarded = ['*'];
    
    public $belongsToMany = [
        'products' => [
            'Tiipiik\Catalog\Models\Product',
            'table' => 'tiipiik_catalog_prods_cats',
            'order' => 'title'
        ],
    ];

    public $attachOne = [
        'cover' => ['System\Models\File']
    ];
    
     /**
     * Add translation support to this model, if available.
     * @return void
     */
    public static function boot()
    {
        // Call default functionality (required)
        parent::boot();

        // Check the translate plugin is installed
        if (!class_exists('RainLab\Translate\Behaviors\TranslatableModel')) {
            return;
        }

        // Extend the constructor of the model
        self::extend(function ($model) {
            // Implement the translatable behavior
            $model->implement[] = 'RainLab.Translate.Behaviors.TranslatableModel';
        });
    }
    
    /*
     *
     */
    public function getCategoriesOptions()
    {
        return $this->orderBy('name')->lists('name', 'id');<commit_msg>Update Category.php<commit_after><?php namespace Tiipiik\Catalog\Models;

use Model;
use Cms\Classes\Page as CmsPage;
use Cms\Classes\Theme;

/**
 * Category Model
 */
class Category extends Model
{
    use \October\Rain\Database\Traits\NestedTree;
    use \October\Rain\Database\Traits\Validation;

    /**
     * @var string The database table used by the model.
     */
    public $table = 'tiipiik_catalog_categories';

    /**
     * Validation rules
     */
    public $rules = [
        'name' => 'required|unique:tiipiik_catalog_categories',
        'slug' => 'required',
    ];

    /**
     * @var array Translatable fields
     */
    public $translatable = ['name', 'description'];
    
    /**
     * @var array Guarded fields
     */
    protected $guarded = ['*'];
    
    public $belongsToMany = [
        'products' => [
            'Tiipiik\Catalog\Models\Product',
            'table' => 'tiipiik_catalog_prods_cats',
            'order' => 'title'
        ],
    ];

    public $attachOne = [
        'cover' => ['System\Models\File','delete' => true]
    ];
    
     /**
     * Add translation support to this model, if available.
     * @return void
     */
    public static function boot()
    {
        // Call default functionality (required)
        parent::boot();

        // Check the translate plugin is installed
        if (!class_exists('RainLab\Translate\Behaviors\TranslatableModel')) {
            return;
        }

        // Extend the constructor of the model
        self::extend(function ($model) {
            // Implement the translatable behavior
            $model->implement[] = 'RainLab.Translate.Behaviors.TranslatableModel';
        });
    }
    
    /*
     *
     */
    public function getCategoriesOptions()
    {
        return $this->orderBy('name')->lists('name', 'id');
{'fraction_non_alphanumeric': 0.13410277548777136, 'fraction_numerical': 0.0, 'mean_word_length': 2.061396131202691, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 22, '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': '1159506', 'n_tokens_mistral': 1083, 'n_tokens_neox': 1058, 'n_words': 231}