belongsTo('App\Models\Invoice')->withTrashed(); } /** * @return mixed */ public function contact() { return $this->belongsTo('App\Models\Contact')->withTrashed(); } /** * @return mixed */ public function user() { return $this->belongsTo('App\Models\User')->withTrashed(); } /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function account() { return $this->belongsTo('App\Models\Account'); } public function signatureDiv() { if (! $this->signature_base64) { return false; } return sprintf('
%s: %s', $this->signature_base64, trans('texts.signed'), Utils::fromSqlDateTime($this->signature_date)); } } Invitation::creating(function ($invitation) { LookupInvitation::createNew($invitation->account->account_key, [ 'invitation_key' => $invitation->invitation_key, ]); }); Invitation::updating(function ($invitation) { $dirty = $invitation->getDirty(); if (array_key_exists('message_id', $dirty)) { LookupInvitation::updateInvitation($invitation->account->account_key, $invitation); } }); Invitation::deleted(function ($invitation) { if ($invitation->forceDeleting) { LookupInvitation::deleteWhere([ 'invitation_key' => $invitation->invitation_key, ]); } });