<?php namespace Tps\Shops\Models;

use Model;
use October\Rain\Database\Traits\Sortable;
use October\Rain\Database\Traits\Validation;

/**
 * Model
 */
class TopCategory extends Model
{
    use Validation;
    use Sortable;

    public $implement = ['RainLab.Translate.Behaviors.TranslatableModel'];
    /*
     * Disable timestamps by default.
     * Remove this line if timestamps are defined in the database table.
     */
    public $timestamps = false;

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

    /**
     * @var array Validation rules
     */
    public $rules = [
    ];

    public $hasMany = [
        'categories' => [
            'Tps\Shops\Models\Category',
        ]
    ];

    public $translatable = ['name'];

    public function getCategories($limit = 5){
        return Category::where('top_category_id', $this->id)->limit($limit)->get();
    }
}
