52 lines
1.2 KiB
PHP
52 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Response;
|
|
use Illuminate\Http\Request;
|
|
use App\Contracts\HttpStatusCodeInterface;
|
|
use App\Abstracts\CustomFormRequest;
|
|
use App\CodeCardType;
|
|
|
|
class TopUpFormValidation extends CustomFormRequest
|
|
{
|
|
private $status;
|
|
|
|
public function __construct(HttpStatusCodeInterface $httpStatusCode)
|
|
{
|
|
$this->status = $httpStatusCode;
|
|
}
|
|
|
|
|
|
public function authorize()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules(Request $request)
|
|
{
|
|
|
|
$rules = [
|
|
'fee_code' => $this->method() == 'POST' ? 'required|unique:top_up,fee_code,null,null,is_active,1|string' : 'required|string',
|
|
'name' => 'required|string',
|
|
'amount' => $request->type == 1 ? 'required|numeric|between:0,99999.99' : 'required|numeric|between:0,100' ,
|
|
'type' => 'required|in:1,2',
|
|
];
|
|
return $rules;
|
|
|
|
}
|
|
|
|
public function response(array $errors)
|
|
{
|
|
return $this->status->unprocessableEntity('Form Validation Error',$errors);
|
|
}
|
|
|
|
}
|
|
|
|
?>
|