<?php

/**
 * Created by Reliese Model.
 */

namespace App\Models;

use Carbon\Carbon;
use GeneaLabs\LaravelModelCaching\Traits\Cachable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * Class Category
 *
 * @property int $id
 * @property int $country_locale_id
 * @property string|null $name
 * @property string $short_name
 * @property string|null $slug
 * @property bool $enabled
 * @property bool $is_top
 * @property int $_lft
 * @property int $_rgt
 * @property int|null $parent_id
 * @property string|null $deleted_at
 * @property Carbon|null $created_at
 * @property Carbon|null $updated_at
 * @property CountryLocale $country_locale
 */
class Category extends Model
{
    use SoftDeletes, Cachable;

    protected $table = 'categories';

    protected $casts = [
        'country_locale_id' => 'int',
        'enabled' => 'bool',
        'is_top' => 'bool',
        '_lft' => 'int',
        '_rgt' => 'int',
        'parent_id' => 'int',
    ];

    protected $fillable = [
        'country_locale_id',
        'name',
        'short_name',
        'slug',
        'description',
        'enabled',
        'is_top',
        '_lft',
        '_rgt',
        'parent_id',
    ];

    public function country_locale()
    {
        return $this->belongsTo(CountryLocale::class);
    }
}
