<?php

namespace Modules\Mall\Models;

use App\Models\Model;
use App\Traits\HasCovers;
use App\Traits\HasStatus;
use App\Traits\OrderByOrderAsc;
use Encore\Admin\Traits\AdminBuilder;
use Encore\Admin\Traits\ModelTree;
use GeneaLabs\LaravelModelCaching\Traits\Cachable;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Modules\Mall\Models\Traits\BelongsToShop;
use Overtrue\LaravelVersionable\Versionable;

class Category extends Model
{

    use AdminBuilder,
        BelongsToShop,
        Cachable,
        HasCovers,
        ModelTree,
        OrderByOrderAsc,
        HasStatus,
        Versionable,
        SoftDeletes;

    protected $table = 'mall_categories';

    /**
     * 不参与版本记录的字段
     * @var array|string[]
     */
    protected array $dontVersionable = ['updated_at'];

    public function __construct(array $attributes = [])
    {
        parent::__construct($attributes);

        $this->setTitleColumn('name');
    }

    /**
     * Notes   : 分类商品
     * @Date   : 2021/5/12 9:49 上午
     * @Author : < Jason.C >
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function goods(): HasMany
    {
        return $this->hasMany(Goods::class);
    }

}
