1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-21 17:01:33 +02:00
invoiceninja/app/Http/Requests/Statements/CreateStatementRequest.php

72 lines
1.5 KiB
PHP
Raw Normal View History

2021-08-24 13:18:32 +02:00
<?php
namespace App\Http\Requests\Statements;
2021-08-24 15:31:40 +02:00
use App\Models\Invoice;
use App\Models\Payment;
2021-08-24 13:18:32 +02:00
use Illuminate\Foundation\Http\FormRequest;
class CreateStatementRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize(): bool
{
return auth()->user()->isAdmin();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'start_date' => ['required'],
'end_date' => ['required'],
];
}
2021-08-24 15:31:40 +02:00
/**
* The collection of invoices for the statement.
*
* @return Invoice[]|\Illuminate\Database\Eloquent\Collection
*/
public function getInvoices()
{
// $this->request->start_date & $this->request->end_date are available.
return Invoice::all();
}
/**
* The collection of payments for the statement.
*
* @return Payment[]|\Illuminate\Database\Eloquent\Collection
*/
public function getPayments()
{
// $this->request->start_date & $this->request->end_date are available.
return Payment::all();
}
/**
* The array of aging data.
*/
public function getAging(): array
{
return [
'0-30' => 1000,
'30-60' => 2000,
'60-90' => 3000,
'90-120' => 4000,
'120+' => 5000,
];
}
2021-08-24 13:18:32 +02:00
}