初始化提交
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $area_id 地区编号
|
||||
* @property string $area_name 名称
|
||||
* @property int $parent_id 上级编号
|
||||
* @property string $zip 邮编
|
||||
* @property int $area_type 类型(1:国家,2:省,3:市,4:区县)
|
||||
*/
|
||||
class Area extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'area';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['area_id', 'area_name', 'parent_id', 'zip', 'area_type'];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*/
|
||||
protected array $casts = ['area_id' => 'integer', 'parent_id' => 'integer', 'area_type' => 'integer'];
|
||||
|
||||
protected string $primaryKey = "area_id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->first($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据-多
|
||||
* @param array $params
|
||||
* @param array $field
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getList(array $params = [], array $field = ['*']): Collection|array
|
||||
{
|
||||
return self::where($params)->get($field);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user