2021-03-29 14:35:27 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2023-01-28 23:21:40 +01:00
|
|
|
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
2021-03-29 14:35:27 +02:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2021-03-29 14:35:27 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\ClientPortal;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
2023-01-12 05:58:02 +01:00
|
|
|
use App\Http\Requests\ClientPortal\RecurringInvoices\ShowRecurringInvoiceRequest;
|
2021-11-15 23:59:55 +01:00
|
|
|
use App\Models\RecurringInvoice;
|
|
|
|
use App\Utils\Ninja;
|
2021-03-29 14:35:27 +02:00
|
|
|
|
|
|
|
class SubscriptionController extends Controller
|
|
|
|
{
|
|
|
|
public function index()
|
|
|
|
{
|
2023-03-22 02:42:38 +01:00
|
|
|
// if (Ninja::isHosted()) {
|
|
|
|
// $count = RecurringInvoice::query()
|
|
|
|
// ->where('client_id', auth()->guard('contact')->user()->client->id)
|
|
|
|
// ->where('company_id', auth()->guard('contact')->user()->client->company_id)
|
|
|
|
// ->where('status_id', RecurringInvoice::STATUS_ACTIVE)
|
|
|
|
// ->where('is_deleted', 0)
|
|
|
|
// ->whereNotNull('subscription_id')
|
|
|
|
// ->withTrashed()
|
|
|
|
// ->count();
|
2021-11-15 23:59:55 +01:00
|
|
|
|
2023-03-22 02:42:38 +01:00
|
|
|
// if ($count == 0) {
|
|
|
|
// return redirect()->route('client.ninja_contact_login', ['contact_key' => auth()->guard('contact')->user()->contact_key, 'company_key' => auth()->guard('contact')->user()->company->company_key]);
|
|
|
|
// }
|
|
|
|
// }
|
2021-11-15 23:59:55 +01:00
|
|
|
|
2021-03-29 14:35:27 +02:00
|
|
|
return render('subscriptions.index');
|
|
|
|
}
|
2023-01-12 05:58:02 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the recurring invoice.
|
|
|
|
*
|
|
|
|
* @param ShowRecurringInvoiceRequest $request
|
|
|
|
* @param RecurringInvoice $recurring_invoice
|
|
|
|
* @return Factory|View
|
|
|
|
*/
|
|
|
|
public function show(ShowRecurringInvoiceRequest $request, RecurringInvoice $recurring_invoice)
|
|
|
|
{
|
|
|
|
return $this->render('subscriptions.show', [
|
2023-02-16 02:36:09 +01:00
|
|
|
'invoice' => $recurring_invoice->load('invoices', 'subscription'),
|
2023-01-12 05:58:02 +01:00
|
|
|
'subscription' => $recurring_invoice->subscription
|
|
|
|
]);
|
|
|
|
}
|
2021-03-29 14:35:27 +02:00
|
|
|
}
|