bztang-admin/app/common/models/weightValue/WeightValueLog.php

84 lines
1.9 KiB
PHP

<?php
namespace app\common\models\weightValue;
use app\common\models\BaseModel;
use app\common\models\Member;
use function PHPUnit\Framework\isNull;
class WeightValueLog extends BaseModel{
public $timestamps = false;
public $table = 'yz_weight_value_log';
public $casts = [
'created_at' => 'datetime:Y-m-d h:i:s'
];
protected $fillable = [
'uniacid',
'member_id',
'type',
'goods_id',
'order_id',
'order_goods_id',
'change_type',
'change_quantity',
'change_front',
'change_after',
'remark',
'created_at',
];
/**
* Common: 获取列表
* Author: wu-hui
* Time: 2023/09/27 14:04
* @param $pageSize
* @param $search
* @param string[] $field
* @return array
*/
public function getList($pageSize,$search,$field = ['*']){
// 条件生成
$where = [];
if($search['member_id'] > 0) $where[] = ['member_id','=',$search['member_id']];
// if($search['type'] >= 0 && !is_null($search['type'])) $where[] = ['type','=',$search['type']];
// if($search['change_type'] >= 0 && !is_null($search['type'])) $where[] = ['change_type','=',$search['change_type']];
// 列表获取
$list = self::uniacid()
->select($field)
->where($where)
->with(['member'=>function($query){
$query->select(['uid','nickname','realname','avatar']);
}])
->orderBy('created_at','DESC')
->orderBy('id','DESC')
->paginate($pageSize);
return $list ? $list->toArray() : [];
}
/**
* Common: 一对一关联 用户信息
* Author: wu-hui
* Time: 2023/09/27 13:43
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function member(){
return $this->hasOne(Member::class, 'uid', 'member_id');
}
}