2021-03-29 14:35:27 +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-03-29 14:35:27 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\ClientPortal;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
2021-11-15 23:59:55 +01:00
|
|
|
use App\Models\RecurringInvoice;
|
|
|
|
use App\Utils\Ninja;
|
2021-03-29 14:35:27 +02:00
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
class SubscriptionController extends Controller
|
|
|
|
{
|
|
|
|
public function index()
|
|
|
|
{
|
2021-11-15 23:59:55 +01:00
|
|
|
|
|
|
|
if(Ninja::isHosted()){
|
|
|
|
|
|
|
|
|
|
|
|
$count = RecurringInvoice::query()
|
2022-02-16 03:24:10 +01:00
|
|
|
->where('client_id', auth()->guard('contact')->user()->client->id)
|
|
|
|
->where('company_id', auth()->guard('contact')->user()->client->company_id)
|
2021-11-15 23:59:55 +01:00
|
|
|
->where('status_id', RecurringInvoice::STATUS_ACTIVE)
|
2021-11-16 00:35:22 +01:00
|
|
|
->where('is_deleted', 0)
|
2021-11-15 23:59:55 +01:00
|
|
|
->whereNotNull('subscription_id')
|
2021-11-16 00:35:22 +01:00
|
|
|
->withTrashed()
|
2021-11-15 23:59:55 +01:00
|
|
|
->count();
|
|
|
|
|
|
|
|
if($count == 0)
|
2022-02-16 03:24:10 +01:00
|
|
|
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');
|
|
|
|
}
|
|
|
|
}
|