Merge pull request #2867 from novag/master
add document deleting and document deleted events
This commit is contained in:
commit
e0a2930011
20
app/Events/Document/DocumentDeleted.php
Normal file
20
app/Events/Document/DocumentDeleted.php
Normal file
@ -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
app/Events/Document/DocumentDeleting.php
Normal file
20
app/Events/Document/DocumentDeleting.php
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,8 @@
|
|||||||
namespace App\Jobs\Document;
|
namespace App\Jobs\Document;
|
||||||
|
|
||||||
use App\Abstracts\Job;
|
use App\Abstracts\Job;
|
||||||
|
use App\Events\Document\DocumentDeleted;
|
||||||
|
use App\Events\Document\DocumentDeleting;
|
||||||
use App\Interfaces\Job\ShouldDelete;
|
use App\Interfaces\Job\ShouldDelete;
|
||||||
use App\Observers\Transaction;
|
use App\Observers\Transaction;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
@ -13,6 +15,8 @@ class DeleteDocument extends Job implements ShouldDelete
|
|||||||
{
|
{
|
||||||
$this->authorize();
|
$this->authorize();
|
||||||
|
|
||||||
|
event(new DocumentDeleting($this->model));
|
||||||
|
|
||||||
\DB::transaction(function () {
|
\DB::transaction(function () {
|
||||||
Transaction::mute();
|
Transaction::mute();
|
||||||
|
|
||||||
@ -25,6 +29,8 @@ class DeleteDocument extends Job implements ShouldDelete
|
|||||||
Transaction::unmute();
|
Transaction::unmute();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
event(new DocumentDeleted($this->model));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user