first(); $invitation = InvoiceInvitation::whereRaw("BINARY `invitation_key`= ?", [$invitation_key])->first(); if($invitation){ $invitation->markViewed(); Auth::guard('contact')->loginUsingId($invitation->client_contact_id, true); return redirect()->route('client.invoice.show', ['invoice' => $this->encodePrimaryKey($invitation->invoice_id)]); } else abort(404); } }