<?php
declare (strict_types = 1);

namespace app\index\model;

use app\common\model\SysMallStoreEntranceBaseModel;
use think\model\concern\SoftDelete;

/**
 * 系统商城店铺入口模型
 * @mixin \think\Model
 */
class SysMallStoreEntranceModel extends SysMallStoreEntranceBaseModel
{
    // 启用软删除
    use SoftDelete;
    // 软删除字段
    protected $deleteTime = 'deleted_at';

    // 关联语言
    public function language()
    {
        return $this->belongsTo(\app\index\model\LanguageModel::class, 'language_id', 'id');
    }

    // 所属语言范围查询
    public function scopeLanguage($query, $language)
    {
        $query->where($this->getTable() . '.language_id', '=', $language);
    }

    // 查询启用状态
    public function scopeEnabled($query)
    {
        $query->where('disabled', '=', 0);
    }

    // 查询禁用状态
    public function scopeDisabled($query)
    {
        $query->where('disabled', '=', 1);
    }
}
