添加发起砍价人的名称
parent
0ba1c7b985
commit
566a39522b
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Reference in New Issue