82 lines
2.0 KiB
PHP
82 lines
2.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Model;
|
|
|
|
|
|
|
|
use Carbon\Carbon;
|
|
use Hyperf\Database\Model\Collection;
|
|
use Hyperf\Snowflake\Concern\Snowflake;
|
|
|
|
/**
|
|
* @property int $package_product_id 主键id
|
|
* @property int $package_id 健康包id
|
|
* @property int $product_id 商品id
|
|
* @property string $product_name 商品名称
|
|
* @property int $quantity 数量
|
|
* @property string $discount_product_price 折扣商品价格
|
|
* @property \Carbon\Carbon $created_at 创建时间
|
|
* @property \Carbon\Carbon $updated_at 修改时间
|
|
*/
|
|
class HealthPackageProduct extends Model
|
|
{
|
|
use Snowflake;
|
|
|
|
/**
|
|
* The table associated with the model.
|
|
*/
|
|
protected ?string $table = 'health_package_product';
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*/
|
|
protected array $fillable = ['package_product_id', 'package_id', 'product_id', 'product_name', 'quantity', 'discount_product_price', 'created_at', 'updated_at'];
|
|
|
|
protected string $primaryKey = "package_product_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 $data
|
|
* @return HealthPackageProduct|\Hyperf\Database\Model\Model
|
|
*/
|
|
public static function addHealthPackageProduct(array $data): \Hyperf\Database\Model\Model|HealthPackageProduct
|
|
{
|
|
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);
|
|
}
|
|
}
|