<?php
declare (strict_types = 1);

namespace app\index\model;

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

/**
 * 横幅模型
 * @mixin \think\Model
 */
class SysBannerItemModel extends SysBannerItemBaseModel
{
    // 启用软删除
    use SoftDelete;
    // 软删除字段
    protected $deleteTime = 'deleted_at';

    // 关联分类
    public function banner()
    {
        return $this->hasOne(SysBannerModel::class, 'id', 'banner_id');
    }

    // 类型范围查询
    public function scopeType($query, $type)
    {
        $query->where('type', '=', $type);
    }

    // 启用状态范围查询
    public function scopeEnabled($query)
    {
        $query->where('status', '=', 1);
    }
}
