1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-06 03:02:34 +01:00
invoiceninja/app/Http/Controllers/ClientPortal/InvitationController.php
David Bomba dc8ecbeeed
Fixes for company_user (#3477)
* Minor fixes for user delete

* Working on notifications

* Refactor for notifications

* Fix for checking settings withe negative integers

* Set payment id to 0

* Move pdf download to client side routes

* fixes for company_user

* Fixes for company_user
2020-03-11 22:05:05 +11:00

72 lines
1.9 KiB
PHP

<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Http\Controllers\ClientPortal;
use App\Events\Misc\InvitationWasViewed;
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 router(string $entity, string $invitation_key)
{
$key = $entity.'_id';
$entity_obj = 'App\Models\\'.ucfirst($entity).'Invitation';
$invitation = $entity_obj::whereRaw("BINARY `key`= ?", [$invitation_key])->first();
if ($invitation) {
if ((bool)$invitation->contact->client->getSetting('enable_client_portal_password') !== false) {
$this->middleware('auth:contact');
} else {
auth()->guard('contact')->login($invitation->contact, false);
}
if(!request()->has('silent')){
$invitation->markViewed();
event(new InvitationWasViewed($entity, $invitation));
}
return redirect()->route('client.'.$entity.'.show', [$entity => $this->encodePrimaryKey($invitation->{$key})]);
} else
abort(404);
}
public function routerForDownload(string $entity, string $invitation_key)
{
return redirect('client/'.$entity.'/'.$invitation_key.'/download_pdf');
}
public function routerForIframe(string $entity, string $client_hash, string $invitation_key)
{
}
}