57 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PHP
		
	
	
			
		
		
	
	
			57 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PHP
		
	
	
<?php
 | 
						|
 | 
						|
namespace app\model;
 | 
						|
 | 
						|
 | 
						|
use think\Collection;
 | 
						|
 | 
						|
class Area extends Base
 | 
						|
{
 | 
						|
 | 
						|
    /**
 | 
						|
     *
 | 
						|
     * @param $PCode
 | 
						|
     * @param $filter bool 是否过滤屏蔽的地区
 | 
						|
     * @return Area[]|array|\think\Collection
 | 
						|
     * @throws \think\db\exception\DataNotFoundException
 | 
						|
     * @throws \think\db\exception\DbException
 | 
						|
     * @throws \think\db\exception\ModelNotFoundException
 | 
						|
     */
 | 
						|
    public static function getByPCode($PCode,bool $filter = false)
 | 
						|
    {
 | 
						|
        return self::where("pcode",$PCode)->when($filter,function ($q){
 | 
						|
            $q->where("status",self::COMMON_ON);
 | 
						|
        })
 | 
						|
            ->field("id,code,pcode,name,status")
 | 
						|
            ->order("id asc")->select();
 | 
						|
    }
 | 
						|
/**
 | 
						|
     *
 | 
						|
     * @param $PCode
 | 
						|
     * @param $filter bool 是否过滤屏蔽的地区
 | 
						|
     * @return Area[]|array|\think\Collection
 | 
						|
     * @throws \think\db\exception\DataNotFoundException
 | 
						|
     * @throws \think\db\exception\DbException
 | 
						|
     * @throws \think\db\exception\ModelNotFoundException
 | 
						|
     */
 | 
						|
    public static function getByPCodes($PCodes,bool $filter = false)
 | 
						|
    {
 | 
						|
        return self::where("pcode","in",$PCodes) ->when($filter,function ($q){
 | 
						|
            $q->where("status",self::COMMON_ON);
 | 
						|
        })
 | 
						|
            ->field("id,code,pcode,name,status")
 | 
						|
            ->order("id asc")
 | 
						|
            ->select()
 | 
						|
            ->toArray();
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    // 获取列表
 | 
						|
    public static function getAllList(): Collection
 | 
						|
    {
 | 
						|
        return self::order('id', 'asc')
 | 
						|
            ->select();
 | 
						|
    }
 | 
						|
}
 |