mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 06:04:34 -04:00
Fixes for invoice invitations (#3306)
This commit is contained in:
parent
d77c662ee9
commit
c6216fb128
@ -67,16 +67,17 @@ class InvoiceRepository extends BaseRepository {
|
|||||||
if (isset($data['invitations'])) {
|
if (isset($data['invitations'])) {
|
||||||
$invitations = collect($data['invitations']);
|
$invitations = collect($data['invitations']);
|
||||||
|
|
||||||
/* Get array of Keyss which have been removed from the invitations array and soft delete each invitation */
|
/* Get array of Keys which have been removed from the invitations array and soft delete each invitation */
|
||||||
collect($invoice->invitations->pluck('key'))->diff($invitations->pluck('key'))->each(function ($invitation) {
|
collect($invoice->invitations->pluck('key'))->diff($invitations->pluck('key'))->each(function ($invitation) {
|
||||||
InvoiceInvitation::destroy($invitation);
|
InvoiceInvitation::whereRaw("BINARY `key`= ?", [$invitation])->delete();
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach ($data['invitations'] as $invitation) {
|
foreach ($data['invitations'] as $invitation) {
|
||||||
$inv = false;
|
$inv = false;
|
||||||
|
|
||||||
if (array_key_exists('key', $invitation)) {
|
if (array_key_exists('key', $invitation)) {
|
||||||
$inv = InvoiceInvitation::whereKey($invitation['key'])->first();
|
// $inv = InvoiceInvitation::whereKey($invitation['key'])->first();
|
||||||
|
$inv = InvoiceInvitation::whereRaw("BINARY `key`= ?", [$invitation['key']])->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$inv) {
|
if (!$inv) {
|
||||||
|
@ -11,24 +11,23 @@
|
|||||||
|
|
||||||
namespace App\Transformers;
|
namespace App\Transformers;
|
||||||
|
|
||||||
use App\Models\Invoice;
|
|
||||||
use App\Models\InvoiceInvitation;
|
use App\Models\InvoiceInvitation;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
|
|
||||||
class InvoiceInvitationTransformer extends EntityTransformer
|
class InvoiceInvitationTransformer extends EntityTransformer {
|
||||||
{
|
use MakesHash;
|
||||||
use MakesHash;
|
|
||||||
|
|
||||||
public function transform(InvoiceInvitation $invitation)
|
public function transform(InvoiceInvitation $invitation) {
|
||||||
{
|
return [
|
||||||
return [
|
'id' => $this->encodePrimaryKey($invitation->id),
|
||||||
'id' => $this->encodePrimaryKey($invitation->id),
|
'client_contact_id' => $this->encodePrimaryKey($invitation->client_contact_id),
|
||||||
'client_contact_id' => $this->encodePrimaryKey($invitation->client_contact_id),
|
'key' => $invitation->key,
|
||||||
'key' => $invitation->key,
|
'link' => $invitation->getLink()?:'',
|
||||||
'link' => $invitation->getLink() ?: '',
|
'sent_date' => $invitation->sent_date?:'',
|
||||||
'sent_date' => $invitation->sent_date ?: '',
|
'viewed_date' => $invitation->viewed_date?:'',
|
||||||
'viewed_date' => $invitation->viewed_date ?: '',
|
'opened_date' => $invitation->opened_date?:'',
|
||||||
'opened_date' => $invitation->opened_date ?: '',
|
'updated_at' => (int) $invitation->updated_at,
|
||||||
];
|
'archived_at' => (int) $invitation->deleted_at,
|
||||||
}
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user