<?php
namespace App\Http\Controllers\Api\V1;
use App\Models\WalletAddress;
use App\Support\ApiResponse;
use Illuminate\Http\Request;
final class AddressAdminController {
 public function index(Request $r){$q=WalletAddress::query()->where('merchant_id',$r->attributes->get('merchant')->id)->where('environment',$r->attributes->get('environment'));return ApiResponse::success($q->latest()->paginate(min(100,(int)$r->input('per_page',20))));}
 public function update(Request $r,int $id){$a=WalletAddress::where('merchant_id',$r->attributes->get('merchant')->id)->where('environment',$r->attributes->get('environment'))->findOrFail($id);$data=$r->validate(['alias'=>'sometimes|string|max:100','status'=>'sometimes|in:active,disabled','callback_url'=>'sometimes|nullable|url|max:2048']);$a->fill($data)->save();return ApiResponse::success($a->fresh());}
}
