71 lines
1.6 KiB
PHP
71 lines
1.6 KiB
PHP
<?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();
|
|
}
|
|
}
|