coupon-admin/app/model/Area.php

58 lines
1.5 KiB
PHP
Raw Normal View History

2021-11-29 09:32:48 +00:00
<?php
namespace app\model;
2021-11-29 10:30:30 +00:00
use think\Collection;
2021-11-29 09:32:48 +00:00
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)
{
2021-12-17 03:41:27 +00:00
return self::where("pcode",$PCode)->when($filter,function ($q){
2021-11-29 09:32:48 +00:00
$q->where("status",self::COMMON_ON);
2021-12-17 03:41:27 +00:00
})
->field("id,code,pcode,name,status")
2022-04-21 03:42:15 +00:00
->order(["sort"=>"desc","id"=>"desc"])
->select();
2021-11-29 09:32:48 +00:00
}
2021-12-17 03:41:27 +00:00
/**
*
* @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")
2022-04-21 03:42:15 +00:00
->order(["sort"=>"desc","id"=>"desc"])
2021-12-17 03:41:27 +00:00
->select()
->toArray();
}
2021-11-29 09:32:48 +00:00
2021-11-29 10:30:30 +00:00
// 获取列表
public static function getAllList(): Collection
{
2022-04-21 04:03:20 +00:00
return self::order(["sort"=>"desc","id"=>"desc"])
2021-11-29 10:30:30 +00:00
->select();
}
2021-11-29 09:32:48 +00:00
}