mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Soft delete/restore tokens in sync with CompanyGateway"
This commit is contained in:
parent
70cb7db12f
commit
458dd1fa4a
@ -87,6 +87,11 @@ class CompanyGateway extends BaseModel
|
|||||||
return $this->belongsTo(Company::class);
|
return $this->belongsTo(Company::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function client_gateway_tokens()
|
||||||
|
{
|
||||||
|
return $this->hasMany(ClientGatewayToken::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function gateway()
|
public function gateway()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Gateway::class, 'gateway_key', 'key');
|
return $this->belongsTo(Gateway::class, 'gateway_key', 'key');
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Observers;
|
namespace App\Observers;
|
||||||
|
|
||||||
|
use App\Models\ClientGatewayToken;
|
||||||
use App\Models\CompanyGateway;
|
use App\Models\CompanyGateway;
|
||||||
|
|
||||||
class CompanyGatewayObserver
|
class CompanyGatewayObserver
|
||||||
@ -41,7 +42,8 @@ class CompanyGatewayObserver
|
|||||||
*/
|
*/
|
||||||
public function deleted(CompanyGateway $company_gateway)
|
public function deleted(CompanyGateway $company_gateway)
|
||||||
{
|
{
|
||||||
//
|
//when we soft delete a gateway - we also soft delete the tokens
|
||||||
|
$company_gateway->client_gateway_tokens()->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,7 +54,8 @@ class CompanyGatewayObserver
|
|||||||
*/
|
*/
|
||||||
public function restored(CompanyGateway $company_gateway)
|
public function restored(CompanyGateway $company_gateway)
|
||||||
{
|
{
|
||||||
//
|
//When we restore the gateway, bring back the tokens!
|
||||||
|
ClientGatewayToken::where('company_gateway_id', $company_gateway->id)->withTrashed()->get()->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user