protected function getHash($pin, $number, $table = "customers", $pk) { $hashed = Shahash::make($pin, $options = array("number" => $number, "key_salt" => $this->salt)); if (DB::update($table, array("hashed" => $hashed, "phone" => $number, "key_salt" => $this->salt, "id" => $pk))) { return true; } else { throw new \RuntimeException("Pin generation process error"); } //echo $myobj->offsetGet("hashed"); //return $hashed; }
*/ $app->post("/merchants/create/", function ($request, $response, $args) { try { $json = $request->getBody(); $data = json_decode($json, true); $merchant = new \models\Merchant(); //$ticketing = json_decode($args['ticketing']); if (!empty($data)) { foreach ($data as $key => $val) { $merchant->{$key} = $val; } } $merchant->created_at = date("Y-m-d H:i:s"); $input['number'] = $data['phone']; $input['key_salt'] = ""; $merchant->password = \system\library\Hashing\Shahash::make($data['password'], $input); $v = new system\library\Validator\Validator(array(new system\library\Validator\Validate\Unique("email", "is already existing", "merchants"), new system\library\Validator\Validate\Required('email', " is required"), new system\library\Validator\Validate\Unique("phone", "is already existing", "merchants"), new system\library\Validator\Validate\Unique("app_id", "is already existing", "merchants"), new system\library\Validator\Validate\Required('phone', " is required")), $data); if ($v->execute() == true) { if ($merchant->create()) { if (isset($input['phone'])) { $merchant->pinAction($merchant->id, $data); } // $result = array(); $result['success'] = true; $result['msg'] = "Record Created"; $result['data'] = $merchant->id; $result['code'] = "200"; } else { //$result = array(); $result['success'] = false; $result['msg'] = "Merchant could not be created";