whereDoesntHave('prize', fn ($builder) => $builder->where('type', DrawPrizeType::None)) ->where('draw_activity_id', $drawActivityId) ->latest('id') ->simplePaginate($request->input('per_page')); return DrawLogResource::collection($drawLogs); } public function update($drawActivityId, $drawLogId, Request $request) { $request->validate([ 'consignee_name' => ['bail', 'required', 'string', 'max:255'], 'consignee_phone' => ['bail', 'required', 'string', 'max:255'], 'consignee_address' => ['bail', 'required', 'string', 'max:255'], ], [], [ 'consignee_name' => '收件人', 'consignee_phone' => '联系方式', 'consignee_address' => '收货地址', ]); $drawLog = DrawLog::where([ 'user_id' => $request->user()->id, 'draw_activity_id' => $drawActivityId, ])->findOrFail($drawLogId); if ($drawLog->prize->type !== DrawPrizeType::Goods) { throw new BizException('奖品不是实物'); } if (filled($drawLog->consignee_name)) { throw new BizException('请联系客服修改收件人信息'); } $drawLog->update($request->only([ 'consignee_name', 'consignee_phone', 'consignee_address', ])); return DrawLogResource::make($drawLog); } }