1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-15 23:52:33 +01:00
invoiceninja/app/Http/Controllers/ClientPortal/NinjaPlanController.php

57 lines
1.8 KiB
PHP
Raw Normal View History

2021-09-01 06:02:57 +02:00
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Http\Controllers\ClientPortal;
use App\Http\Controllers\Controller;
use App\Http\Requests\ClientPortal\Uploads\StoreUploadRequest;
use App\Libraries\MultiDB;
use App\Models\ClientContact;
2021-09-01 07:03:01 +02:00
use App\Models\Company;
2021-09-01 06:02:57 +02:00
use App\Utils\Ninja;
2021-09-01 07:03:01 +02:00
use Auth;
2021-09-01 06:02:57 +02:00
use Illuminate\Contracts\Routing\ResponseFactory;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class NinjaPlanController extends Controller
{
2021-09-01 07:03:01 +02:00
public function index(string $contact_key, string $company_key)
2021-09-01 06:02:57 +02:00
{
2021-09-01 07:03:01 +02:00
MultiDB::findAndSetDbByCompanyKey($company_key);
$company = Company::where('company_key', $company_key)->first();
2021-09-03 15:24:18 +02:00
nlog("Ninja Plan Controller Company key found {$company->company_key}");
2021-09-01 07:03:01 +02:00
$account = $company->account;
2021-09-01 06:02:57 +02:00
2021-09-03 15:24:18 +02:00
if (Ninja::isHosted() && MultiDB::findAndSetDbByContactKey($contact_key) && $client_contact = ClientContact::where('contact_key', $contact_key)->first())
2021-09-01 07:03:01 +02:00
{
2021-09-03 15:24:18 +02:00
nlog("Ninja Plan Controller - Found and set Client Contact");
2021-09-01 07:03:01 +02:00
Auth::guard('contact')->login($client_contact,true);
2021-09-01 06:02:57 +02:00
/* Current paid users get pushed straight to subscription overview page*/
2021-09-01 06:36:22 +02:00
if($account->isPaidHostedClient())
2021-09-01 06:02:57 +02:00
return redirect('/client/subscriptions');
/* Users that are not paid get pushed to a custom purchase page */
return $this->render('subscriptions.ninja_plan', ['settings' => $client_contact->company->settings]);
}
return redirect()->route('client.catchall');
}
}