public function createBatch()
{
$this->request->setHeader('Content-Type', 'application/json');
$validationRules = [
'*.params_id' => 'required|string|max_length[3]|is_unique[sm_benefit_group.benefitgroup_id]',
'*.params_name' => 'required|string|max_length[100]',
'*.params_gender' => 'required|validBenefitGroupGender',
'*.params_description'=> 'required|string|max_length[255]',
'*.params_created' => 'required|integer',
];
$validationMessages = [
'*.params_id' => [
'required' => 'ID must be required',
'string' => 'ID must be string',
'max_length' => 'ID must be maximum 3 length',
'is_unique' => 'ID already exists, try another unique',
],
'*.params_name' => [
'required' => 'Name must be required',
'string' => 'Name must be string',
'max_length' => 'Name must be maximum 100 length',
],
'*.params_gender' => [
'required' => 'Gender Type must be required',
'validBenefitGroupGender' => 'Gender Type must be string and between ("All","M","F")',
],
'*.params_description' => [
'required' => 'Description must be required',
'string' => 'Description must be string',
'max_length' => 'Description must be maximum 255 length',
],
'*.params_created' => [
'required' => 'Created By must be required',
'integer' => 'Created By must be integer',
],
];
$this->validation->setRules($validationRules, $validationMessages);
if ($this->validation->withRequest($this->request)->run()) {
// insertBatch here
} else {
$response = [
'success' => false,
'status' => 400,
'messages' => 'Validation data benefit group failed!',
'validation' => $this->validation->getErrors(),
];
// Result
return $this->respond($response, 400);
}
}