45 lines
961 B
PHP
45 lines
961 B
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(
|
|
'product_name.required' => 'You need to specify the product name'
|
|
);
|
|
}
|
|
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:/^(0)[89]\d{8}$/',
|
|
'amount' => 'required',
|
|
'product_name' => 'required',
|
|
'refID' => 'required',
|
|
'country' => 'required'
|
|
];
|
|
}
|
|
}
|