1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 05:32:39 +01:00
invoiceninja/app/Http/Controllers/ClientPortal/InvitationController.php
2019-09-24 08:37:38 +10:00

48 lines
1.2 KiB
PHP

<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Http\Controllers\ClientPortal;
use App\Http\Controllers\Controller;
use App\Models\InvoiceInvitation;
use App\Utils\Traits\MakesDates;
use App\Utils\Traits\MakesHash;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
/**
* Class InvitationController
* @package App\Http\Controllers\ClientPortal\InvitationController
*/
class InvitationController extends Controller
{
use MakesHash;
use MakesDates;
public function invoiceRouter(string $invitation_key)
{
// $invitation = InvoiceInvitation::whereInvitationKey($invitation_key)->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);
}
}