2021-11-30 17:34:35 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Listeners;
|
|
|
|
|
|
|
|
use App\Events\GroupDeleting;
|
2022-11-22 15:15:52 +01:00
|
|
|
use App\Models\TwoFAccount;
|
2021-11-30 17:34:35 +01:00
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
|
|
class DissociateTwofaccountFromGroup
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Create the event listener.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle the event.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function handle(GroupDeleting $event)
|
|
|
|
{
|
|
|
|
TwoFAccount::where('group_id', $event->group->id)
|
|
|
|
->update(
|
2022-11-22 15:15:52 +01:00
|
|
|
['group_id' => null]
|
2021-11-30 17:34:35 +01:00
|
|
|
);
|
2022-11-22 15:15:52 +01:00
|
|
|
|
2023-03-02 14:32:53 +01:00
|
|
|
Log::info(sprintf('TwoFAccounts dissociated from group %s (id #%d)', var_export($event->group->name, true), $event->group->id));
|
2021-11-30 17:34:35 +01:00
|
|
|
}
|
|
|
|
}
|