resource; switch ($model->gift_type){ case InviteNewUsersGiveGiftLog::GIFT_TYPE_CARD: $card = CardRiding::find($model->gift_id); $gift_name = $card->name; break; case InviteNewUsersGiveGiftLog::GIFT_TYPE_COUPON: $coupon = Coupon::find($model->gift_id); $gift_name = $coupon->title; break; case InviteNewUsersGiveGiftLog::GIFT_TYPE_BALANCE: $gift_name = '赠送余额'; break; default: $gift_name = ''; } $data = [ 'active_name' => $model->inviteNewUsersConfig->name, 'user_name' => $model->users->nickname . '('.$model->users->truename.')' , 'user_mobile' => $model->users->mobile, 'gift_name' => $gift_name, 'gift_type_name' => InviteNewUsersGiveGiftLog::$giftTypeMaps[$model->gift_type] ]; return array_merge(parent::toArray($request),$data); } }