File "PaymentCollectionReportRequest.php"
Full Path: /home/clickysoft/public_html/jmapi5.clickysoft.net/app/Http/Requests/Admin/PaymentCollectionReportRequest.php
File size: 1.42 KB
MIME-type: text/x-php
Charset: utf-8
<?php
namespace App\Http\Requests\Admin;
use App\Models\Order;
use App\Models\ReportJobsCompletedDetailed;
use App\Models\ReportPaymentsCollection;
use Illuminate\Foundation\Http\FormRequest;
use Gate;
class PaymentCollectionReportRequest extends FormRequest
{
public function authorize()
{
return Gate::allows('jobs_completed_comparison_access');
}
public function rules()
{
return [
'report_type' => [
'nullable',
'in:'. implode(',', array_keys(ReportPaymentsCollection::REPORTS_MODE))
],
'payment_type' => [
'nullable',
'in:'. implode(',', array_keys(Order::PAYMENT_TYPE_RADIO))
],
'year_from' => [
'required_if:report_type,custom',
'date_format:Y',
],
'year_to' => [
'required_if:report_type,custom',
'date_format:Y',
'after_or_equal:year_from',
],
'date' => [
'required_if:report_type,monthly',
'date_format:Y-m',
'before:tomorrow',
],
];
}
public function messages()
{
return [
'year_from.date_format' => 'The year from should be a valid 4 digit year.',
'year_to.date_format' => 'The year to should be a valid 4 digit year.',
];
}
}