1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-21 00:41:34 +02:00

Fixes for invoice invitations (#3306)

This commit is contained in:
David Bomba 2020-02-10 21:44:17 +11:00 committed by GitHub
parent d77c662ee9
commit c6216fb128
2 changed files with 19 additions and 19 deletions

View File

@ -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) {

View File

@ -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,
];
}
}