mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -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'])) {
|
||||
$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) {
|
||||
InvoiceInvitation::destroy($invitation);
|
||||
InvoiceInvitation::whereRaw("BINARY `key`= ?", [$invitation])->delete();
|
||||
});
|
||||
|
||||
foreach ($data['invitations'] as $invitation) {
|
||||
$inv = false;
|
||||
|
||||
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) {
|
||||
|
@ -11,24 +11,23 @@
|
||||
|
||||
namespace App\Transformers;
|
||||
|
||||
use App\Models\Invoice;
|
||||
use App\Models\InvoiceInvitation;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
|
||||
class InvoiceInvitationTransformer extends EntityTransformer
|
||||
{
|
||||
use MakesHash;
|
||||
class InvoiceInvitationTransformer extends EntityTransformer {
|
||||
use MakesHash;
|
||||
|
||||
public function transform(InvoiceInvitation $invitation)
|
||||
{
|
||||
return [
|
||||
'id' => $this->encodePrimaryKey($invitation->id),
|
||||
'client_contact_id' => $this->encodePrimaryKey($invitation->client_contact_id),
|
||||
'key' => $invitation->key,
|
||||
'link' => $invitation->getLink() ?: '',
|
||||
'sent_date' => $invitation->sent_date ?: '',
|
||||
'viewed_date' => $invitation->viewed_date ?: '',
|
||||
'opened_date' => $invitation->opened_date ?: '',
|
||||
];
|
||||
}
|
||||
public function transform(InvoiceInvitation $invitation) {
|
||||
return [
|
||||
'id' => $this->encodePrimaryKey($invitation->id),
|
||||
'client_contact_id' => $this->encodePrimaryKey($invitation->client_contact_id),
|
||||
'key' => $invitation->key,
|
||||
'link' => $invitation->getLink()?:'',
|
||||
'sent_date' => $invitation->sent_date?:'',
|
||||
'viewed_date' => $invitation->viewed_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