Skip to content

Commit

Permalink
add document deleting and document deleted events
Browse files Browse the repository at this point in the history
  • Loading branch information
novag committed Jan 14, 2023
1 parent c34de72 commit b3fb6b9
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
20 changes: 20 additions & 0 deletions app/Events/Document/DocumentDeleted.php
@@ -0,0 +1,20 @@
<?php

namespace App\Events\Document;

use App\Abstracts\Event;

class DocumentDeleted extends Event
{
public $document;

/**
* Create a new event instance.
*
* @param $document
*/
public function __construct($document)
{
$this->document = $document;
}
}
20 changes: 20 additions & 0 deletions app/Events/Document/DocumentDeleting.php
@@ -0,0 +1,20 @@
<?php

namespace App\Events\Document;

use App\Abstracts\Event;

class DocumentDeleting extends Event
{
public $document;

/**
* Create a new event instance.
*
* @param $document
*/
public function __construct($document)
{
$this->document = $document;
}
}
6 changes: 6 additions & 0 deletions app/Jobs/Document/DeleteDocument.php
Expand Up @@ -3,6 +3,8 @@
namespace App\Jobs\Document;

use App\Abstracts\Job;
use App\Events\Document\DocumentDeleted;
use App\Events\Document\DocumentDeleting;
use App\Interfaces\Job\ShouldDelete;
use App\Observers\Transaction;
use Illuminate\Support\Str;
Expand All @@ -13,6 +15,8 @@ public function handle(): bool
{
$this->authorize();

event(new DocumentDeleting($this->model));

\DB::transaction(function () {
Transaction::mute();

Expand All @@ -25,6 +29,8 @@ public function handle(): bool
Transaction::unmute();
});

event(new DocumentDeleted($this->model));

return true;
}

Expand Down

0 comments on commit b3fb6b9

Please sign in to comment.