Update a new payment method as default if current default is deleted
This commit is contained in:
parent
c3d717972b
commit
aea0236068
|
|
@ -417,6 +417,18 @@ class ClientGatewayTokenController extends BaseController
|
|||
{
|
||||
$this->client_gateway_token_repo->delete($client_gateway_token);
|
||||
|
||||
if($client_gateway_token->is_default) {
|
||||
$cgt = ClientGatewayToken::where('client_id', $client_gateway_token->client_id)
|
||||
->where('company_gateway_id', $client_gateway_token->company_gateway_id)
|
||||
->first();
|
||||
|
||||
if($cgt){
|
||||
$cgt->is_default = true;
|
||||
$cgt->save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->itemResponse($client_gateway_token->fresh());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue