%PDF- %GIF98; %PNG;
Server : ApacheSystem : Linux host.digitalbabaji.in 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64 User : addictionfreeind ( 1003) PHP Version : 7.2.34 Disable Function : exec,passthru,shell_exec,system Directory : /home/addictionfreeind/public_html/admin1/app/Http/Requests/Payments/ |
Upload File : |
<?php
namespace App\Http\Requests\Payments;
use App\Helper\Reply;
use Carbon\Carbon;
use Illuminate\Foundation\Http\FormRequest;
class StoreBulkPayments extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules()
{
$rules = [];
$invoiceIds = request()->invoice_number;
foreach ($invoiceIds as $index => $invoiceId) {
$amount = request()->amount[$index];
$transaction_id = request()->transaction_id[$index];
$gateway = request()->gateway[$index];
$offline_method_id = request()->offline_method_id[$index];
$payment_date = request()->payment_date[$index];
if ($gateway != 'all' && $gateway == 'Offline' && $offline_method_id == null) {
$rules['payment_date.'.$index.''] = 'required';
$rules['offline_methods.'.$index.''] = 'required';
$rules['amount.'.$index.''] = 'required';
}
elseif ($gateway != 'all' && $gateway != 'Offline') {
$rules['payment_date.'.$index.''] = 'required';
$rules['amount.'.$index.''] = 'required';
}
if ($gateway != 'all' && $gateway == 'Offline') {
$rules['amount.'.$index.''] = 'required';
}
if ($gateway == 'all' && (!is_null($amount) || $amount != null)) {
$rules['gateway.'.$index.''] = 'required';
}
if (is_null($payment_date) || $payment_date == null) {
$rules['payment_date.'.$index.''] = 'required';
}
}
return $rules;
}
public function messages()
{
$message = [];
$invoiceIds = request()->invoice_number;
foreach ($invoiceIds as $index => $invoiceId) {
$amount = request()->amount[$index];
$transaction_id = request()->transaction_id[$index];
$gateway = request()->gateway[$index];
$offline_method_id = request()->offline_method_id[$index];
$payment_date = request()->payment_date[$index];
if ($gateway != 'all' && $gateway == 'Offline' && $offline_method_id == null)
{
$message['payment_date.'.$index.''] = __('messages.invoiceDateError');
$message['offline_methods.'.$index.''] = __('messages.selectOfflineMethod');
$message['amount.'.$index.''] = __('messages.invoicePaymentError');
}
elseif ($gateway != 'all' && $gateway != 'Offline') {
$message['payment_date.'.$index.''] = __('messages.invoiceDateError');
$message['amount.'.$index.''] = __('messages.invoicePaymentError');
}
if ($gateway != 'all' && $gateway == 'Offline') {
$message['amount.'.$index.''] = __('messages.invoicePaymentError');
}
if ($gateway == 'all' && (!is_null($amount) || $amount != null)) {
$message['gateway.'.$index.''] = __('messages.selectGateway');
}
if (is_null($payment_date) || $payment_date == null) {
$message['payment_date.'.$index.''] = __('messages.invoiceDateError');
}
}
return $message;
}
}