1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 13:42:49 +01:00
invoiceninja/app/Http/Controllers/ClientPortal/SubscriptionPlanSwitchController.php

55 lines
1.6 KiB
PHP
Raw Normal View History

2021-04-07 18:08:26 +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)
*
2021-06-16 08:58:16 +02:00
* @license https://www.elastic.co/licensing/elastic-license
2021-04-07 18:08:26 +02:00
*/
namespace App\Http\Controllers\ClientPortal;
use App\Http\Controllers\Controller;
use App\Http\Requests\ClientPortal\Subscriptions\ShowPlanSwitchRequest;
2021-04-10 06:07:08 +02:00
use App\Models\RecurringInvoice;
2021-04-07 18:08:26 +02:00
use App\Models\Subscription;
use Illuminate\Http\Request;
2021-04-14 04:40:16 +02:00
use Illuminate\Support\Str;
2021-04-07 18:08:26 +02:00
class SubscriptionPlanSwitchController extends Controller
{
/**
* Show the page for switching between plans.
*
* @param ShowPlanSwitchRequest $request
2021-04-10 06:07:08 +02:00
* @param RecurringInvoice $recurring_invoice
* @param string $target
2021-04-07 18:08:26 +02:00
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
2021-04-10 06:07:08 +02:00
public function index(ShowPlanSwitchRequest $request, RecurringInvoice $recurring_invoice, Subscription $target)
2021-04-07 18:08:26 +02:00
{
2021-04-14 04:40:16 +02:00
2021-04-13 11:34:59 +02:00
$amount = $recurring_invoice->subscription
->service()
->calculateUpgradePrice($recurring_invoice, $target);
/**
*
* Null value here is a proxy for
* denying the user a change plan option
*
*/
if(is_null($amount))
render('subscriptions.denied');
2021-07-15 13:00:24 +02:00
2021-04-07 18:08:26 +02:00
return render('subscriptions.switch', [
2021-04-12 13:56:08 +02:00
'subscription' => $recurring_invoice->subscription,
'recurring_invoice' => $recurring_invoice,
'target' => $target,
2021-04-10 06:07:08 +02:00
'amount' => $amount,
2021-04-07 18:08:26 +02:00
]);
}
}