feat : city

This commit is contained in:
2024-10-31 16:30:29 +08:00
parent 39b5df9f0a
commit ceeeea7c34
9 changed files with 534 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
<?php
declare(strict_types=1);
namespace App\Model;
use Hyperf\Database\Model\Builder;
use Hyperf\DbConnection\Model\Model;
/**
* @property int $id
* @property int $pid
* @property int $deep
* @property string $title
*/
class SystemCityConfig extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'system_city_config';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['id' => 'integer', 'pid' => 'integer', 'deep' => 'integer'];
private array $selectFiled = ['id','pid','title'];
/**
* @return array
*/
public function getAll(): array
{
return $this->get($this->selectFiled)->toArray();
}
/**
* @param int $deep
* @return array
*/
public function getListByDeep(int $deep): array
{
return $this->where('deep',$deep)->get($this->selectFiled)->toArray();
}
/**
* @param int $id
* @return Builder|\Hyperf\Database\Model\Model|null
*/
public function getInfoById(int $id): \Hyperf\Database\Model\Model|Builder|null
{
return $this->where('id',$id)->first();
}
/**
* @param int $id
* @param int $pid
* @return \Hyperf\Database\Model\Model|Builder|null
*/
public function getAddressByIdAndPid(int $id, int $pid): \Hyperf\Database\Model\Model|Builder|null
{
return $this->where('id',$id)->where('pid',$pid)->first();
}
}