52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class CollectPaymentsRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function authorize()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function messages(){
|
|
return array(
|
|
'channel.required' => 'You need to specify the channel',
|
|
'payment_mode.required' => 'You need to specify the payment mode',
|
|
'broker_id.required' => 'You need to specify the borker',
|
|
'refID.required' => 'No reference ID found',
|
|
// 'refID.unique' => 'Duplicate refID, check and try again'
|
|
);
|
|
}
|
|
public function responsenn(array $errors){
|
|
// Always return JSON.
|
|
return response()->json($errors, 422);
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules()
|
|
{
|
|
return [
|
|
'msisdn' => 'required|regex:/\d{10}$/',
|
|
'amount' => 'required',
|
|
'country' => 'required',
|
|
'currency' => 'required',
|
|
'channel' => 'required', //web, ussd, mobile app
|
|
'refID' => 'required',
|
|
'payment_mode' => 'required',
|
|
'broker_id' => 'required',
|
|
];
|
|
}
|
|
}
|