user destroying flow updated
This commit is contained in:
parent
127d85d0d9
commit
c846aa0005
@ -16,6 +16,8 @@ class DeleteUser extends Job implements ShouldDelete
|
|||||||
event(new UserDeleting($this->model));
|
event(new UserDeleting($this->model));
|
||||||
|
|
||||||
\DB::transaction(function () {
|
\DB::transaction(function () {
|
||||||
|
$this->deleteRelationships($this->model, ['invitation']);
|
||||||
|
|
||||||
$this->model->delete();
|
$this->model->delete();
|
||||||
|
|
||||||
$this->model->flushCache();
|
$this->model->flushCache();
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Listeners\Auth;
|
|
||||||
|
|
||||||
use App\Events\Auth\UserDeleted as Event;
|
|
||||||
use App\Jobs\Auth\DeleteInvitation;
|
|
||||||
use App\Models\Auth\UserInvitation;
|
|
||||||
use App\Traits\Jobs;
|
|
||||||
|
|
||||||
class DeleteUserInvitation
|
|
||||||
{
|
|
||||||
use Jobs;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle the event.
|
|
||||||
*
|
|
||||||
* @param $event
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function handle(Event $event)
|
|
||||||
{
|
|
||||||
$invitations = UserInvitation::where('user_id', $event->user->id)->get();
|
|
||||||
|
|
||||||
foreach ($invitations as $invitation) {
|
|
||||||
$this->dispatch(new DeleteInvitation($invitation));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -58,6 +58,7 @@ class Version304 extends Listener
|
|||||||
$files = [
|
$files = [
|
||||||
'app/Events/Auth/InvitationCreated.php',
|
'app/Events/Auth/InvitationCreated.php',
|
||||||
'app/Listeners/Auth/SendUserInvitation.php',
|
'app/Listeners/Auth/SendUserInvitation.php',
|
||||||
|
'app/Listeners/Auth/DeleteUserInvitation.php',
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
|
@ -89,6 +89,11 @@ class User extends Authenticatable implements HasLocalePreference
|
|||||||
return $this->belongsToMany('App\Models\Common\Dashboard', 'App\Models\Auth\UserDashboard');
|
return $this->belongsToMany('App\Models\Common\Dashboard', 'App\Models\Auth\UserDashboard');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function invitation()
|
||||||
|
{
|
||||||
|
return $this->hasOne('App\Models\Auth\UserInvitation', 'user_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Always capitalize the name when we retrieve it
|
* Always capitalize the name when we retrieve it
|
||||||
*/
|
*/
|
||||||
|
@ -32,12 +32,6 @@ class Event extends Provider
|
|||||||
'App\Events\Auth\LandingPageShowing' => [
|
'App\Events\Auth\LandingPageShowing' => [
|
||||||
'App\Listeners\Auth\AddLandingPages',
|
'App\Listeners\Auth\AddLandingPages',
|
||||||
],
|
],
|
||||||
'App\Events\Auth\InvitationCreated' => [
|
|
||||||
'App\Listeners\Auth\SendUserInvitation',
|
|
||||||
],
|
|
||||||
'App\Events\Auth\UserDeleted' => [
|
|
||||||
'App\Listeners\Auth\DeleteUserInvitation',
|
|
||||||
],
|
|
||||||
'App\Events\Document\DocumentCreated' => [
|
'App\Events\Document\DocumentCreated' => [
|
||||||
'App\Listeners\Document\CreateDocumentCreatedHistory',
|
'App\Listeners\Document\CreateDocumentCreatedHistory',
|
||||||
'App\Listeners\Document\IncreaseNextDocumentNumber',
|
'App\Listeners\Document\IncreaseNextDocumentNumber',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user