1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-06 03:02:34 +01:00
invoiceninja/app/Http/Controllers/ClientPortal/RecurringInvoiceController.php
Benjamin Beganović 8f4fa5e80d
Client portal improvements (#3607)
* Remove Html\Builder dependency from controllers

* Remove: yajra/laravel-datatables-html

- yajra/laravel-datatables-oracle as main non-dev dependency

* Added sorting to tables
2020-04-09 12:18:07 +10:00

80 lines
2.5 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\Http\Controllers\Controller;
use App\Http\Requests\ClientPortal\ShowRecurringInvoiceRequest;
use App\Models\RecurringInvoice;
use App\Notifications\ClientContactRequestCancellation;
use App\Notifications\ClientContactResetPassword;
use App\Utils\Number;
use App\Utils\Traits\MakesDates;
use App\Utils\Traits\MakesHash;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Notification;
use Yajra\DataTables\Facades\DataTables;
/**
* Class InvoiceController
* @package App\Http\Controllers\ClientPortal\InvoiceController
*/
class RecurringInvoiceController extends Controller
{
use MakesHash;
use MakesDates;
/**
* Show the list of recurring invoices.
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index()
{
$invoices = RecurringInvoice::whereClientId(auth()->user()->client->id)
->whereIn('status_id', [RecurringInvoice::STATUS_PENDING, RecurringInvoice::STATUS_ACTIVE, RecurringInvoice::STATUS_COMPLETED])
->orderBy('status_id', 'asc')
->with('client')
->paginate(10);
return $this->render('recurring_invoices.index', [
'invoices' => $invoices,
]);
}
/**
* Display the recurring invoice.
*
* @param ShowRecurringInvoiceRequest $request
* @param RecurringInvoice $recurring_invoice
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function show(ShowRecurringInvoiceRequest $request, RecurringInvoice $recurring_invoice)
{
return $this->render('recurring_invoices.show', [
'invoice' => $recurring_invoice->load('invoices'),
]);
}
public function requestCancellation(Request $request, RecurringInvoice $recurring_invoice)
{
//todo double check the user is able to request a cancellation
//can add locale specific by chaining ->locale();
$recurring_invoice->user->notify(new ClientContactRequestCancellation($recurring_invoice, auth()->user()));
return $this->render('recurring_invoices.cancellation.index', [
'invoice' => $recurring_invoice,
]);
}
}