<?php
declare (strict_types = 1);

namespace app\admin\model\v1;

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

/**
 * 导航模型
 * @mixin \think\Model
 */
class SysNavigationModel extends SysNavigationBaseModel
{
    // 启用软删除
    use SoftDelete;
    // 软删除字段
    protected $deleteTime = 'deleted_at';

    // 按语言查询
    public function scopeLanguage($query, $value)
    {
        if (is_null($value)) return;
        $query->where('language_id', '=', $value);
    }

    // 名称搜索
    public function searchNameAttr($query, $value)
    {
        if (empty($value)) {
            return;
        }
        $query->where('name', 'like', "%{$value}%");
    }
}
