6
0
Fork 0

添加发起砍价人的名称

release
vine_liutk 2022-04-11 14:52:28 +08:00
parent 0ba1c7b985
commit 566a39522b
3 changed files with 8 additions and 0 deletions

View File

@ -85,6 +85,7 @@ class BargainController extends Controller
'user_id'=> $userId,
])->where('status', '>', 0)
->where('expire_at', '>', now())
->whereNull('order_id')
->orderBy('created_at', 'desc')->first();
if ($order) {
return BargainOrderResource::make($order);
@ -105,6 +106,7 @@ class BargainController extends Controller
'id' => $id,
])->where('status', '>', 0)
->where('expire_at', '>', now())
->whereNull('order_id')
->orderBy('created_at', 'desc')->first();
if ($order) {
return BargainOrderResource::make($order);

View File

@ -21,6 +21,7 @@ class BargainOrderResource extends JsonResource
'logs' => BargainOrderLogResource::collection($this->whenLoaded('logs')),
'expire_at'=> $this->expire_at->format('Y-m-d H:i:s'),
'status' => $this->status,
'user_nickname'=> $this->user->userInfo->nickname ?? '',
'is_owner' => $this->user_id == $userId ? true : false,
];
}

View File

@ -23,6 +23,11 @@ class BargainOrder extends Model
public const ORDER_STATUS_START = 1;
public const ORDER_STATUS_FINISHED = 2;
public function user()
{
return $this->belongsTo(User::class, 'user_id');
}
public function logs()
{
return $this->hasMany(BargainOrderLog::class, 'order_id');