hospital-applets-api/app/Model/UserShipAddress.php
2023-03-20 13:14:50 +08:00

124 lines
3.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
declare(strict_types=1);
namespace App\Model;
use Hyperf\Database\Model\Collection;
use Hyperf\Snowflake\Concern\Snowflake;
/**
* @property int $address_id 主键id
* @property int $user_id 用户id
* @property int $province_id 省份id
* @property string $province 省份
* @property int $city_id 城市id
* @property string $city 城市
* @property int $county_id 区县id
* @property string $county 区县
* @property int $consignee_town_id 镇id
* @property string $consignee_town 镇
* @property string $address 详细地址
* @property string $address_mask 详细地址(掩码)
* @property string $consignee_name 收货人姓名
* @property string $consignee_name_mask 收货人姓名(掩码)
* @property string $consignee_tel 收货人电话
* @property string $consignee_tel_mask 收货人电话(掩码)
* @property string $consignee_zip_code 收货邮编
* @property int $is_default 默认地址0:否 1:是)
* @property int $tag 地址标签1:家 2:公司 3:学校)
* @property \Carbon\Carbon $created_at 创建时间
* @property \Carbon\Carbon $updated_at 修改时间
*/
class UserShipAddress extends Model
{
use Snowflake;
/**
* The table associated with the model.
*/
protected ?string $table = 'user_ship_address';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = ['address_id', 'user_id', 'province_id', 'province', 'city_id', 'city', 'county_id', 'county', 'consignee_town_id', 'consignee_town', 'address', 'address_mask', 'consignee_name', 'consignee_name_mask', 'consignee_tel', 'consignee_tel_mask', 'consignee_zip_code', 'is_default', 'tag', 'created_at', 'updated_at'];
protected string $primaryKey = "address_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 $fields
* @return Collection|array
*/
public static function getList(array $params = [], array $fields = ['*']): Collection|array
{
return self::where($params)->get($fields);
}
/**
* 获取是否存在
* @param array $params
* @return bool
*/
public static function getExists(array $params): bool
{
return self::where($params)->exists();
}
/**
* 获取数量
* @param array $params
* @return int
*/
public static function getCount(array $params): int
{
return self::where($params)->count();
}
/**
* 新增
* @param array $data
* @return \Hyperf\Database\Model\Model|UserShipAddress
*/
public static function addUserShipAddress(array $data): \Hyperf\Database\Model\Model|UserShipAddress
{
return self::create($data);
}
/**
* 修改
* @param array $params
* @param array $data
* @return int
*/
public static function edit(array $params = [], array $data = []): int
{
return self::where($params)->update($data);
}
/**
* 删除
* @param array $params
* @return int|mixed
*/
public static function deleteUserShipAddress(array $params): mixed
{
return self::where($params)->delete();
}
}