mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fix SendNotificationEmail job for archived invoices
This commit is contained in:
parent
1edb480ae5
commit
80010880bb
@ -7,13 +7,16 @@ use App\Ninja\Mailers\UserMailer;
|
|||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use App\Models\Traits\SerialisesDeletedModels;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class SendInvoiceEmail.
|
* Class SendInvoiceEmail.
|
||||||
*/
|
*/
|
||||||
class SendNotificationEmail extends Job implements ShouldQueue
|
class SendNotificationEmail extends Job implements ShouldQueue
|
||||||
{
|
{
|
||||||
use InteractsWithQueue, SerializesModels;
|
use InteractsWithQueue, SerializesModels, SerialisesDeletedModels {
|
||||||
|
SerialisesDeletedModels::getRestoredPropertyValue insteadof SerializesModels;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var User
|
* @var User
|
||||||
|
36
app/Models/Traits/SerialisesDeletedModels.php
Normal file
36
app/Models/Traits/SerialisesDeletedModels.php
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Traits;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Database\ModelIdentifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class SerialisesDeletedModels
|
||||||
|
* @see https://github.com/laravel/framework/issues/9347#issuecomment-165647596
|
||||||
|
*/
|
||||||
|
trait SerialisesDeletedModels
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param $value
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
protected function getRestoredPropertyValue($value)
|
||||||
|
{
|
||||||
|
if (!$value instanceof ModelIdentifier) {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_array($value->id)) {
|
||||||
|
return $this->restoreCollection($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
$instance = new $value->class;
|
||||||
|
$query = $instance->newQuery()->useWritePdo();
|
||||||
|
|
||||||
|
if (property_exists($instance, 'forceDeleting')) {
|
||||||
|
return $query->withTrashed()->find($value->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query->findOrFail($value->id);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user