This commit is contained in:
mikael-zakaria 2025-09-12 11:28:00 +07:00
commit e861819b6e
2 changed files with 12 additions and 12 deletions

View File

@ -66,7 +66,7 @@ class CodedText extends Controller {
// Prepare data
$data = $this->prepareData($input, $now, 'create');
if (!$this->validateData($data, $this->rules())) {
if (!$this->validateData($data, $this->rules)) {
return $this->failValidationErrors($this->validator->getErrors());
}
@ -108,8 +108,8 @@ class CodedText extends Controller {
$data = $this->prepareData($input, $now, 'update');
if (!$this->validateData($data, $rules)) {
return $this->failValidationErrors( $this->validator->getErrors());
if (!$this->validateData($data, $this->rules)) {
return $this->failValidationErrors( $this->validator->getErrors() );
}
// Start transaction
@ -154,11 +154,11 @@ class CodedText extends Controller {
return $this->failNotFound("CTID with {$CTID} not found.");
}
$this->db->table('codedtxt')->where('CTID', $CTID)->update(['DelDate' => $this->now()]);
$this->db->table('codedtxt')->where('CTID', $CTID)->update(['EndDate' => $this->now ]);
return $this->respondDeleted([
'status' => 'success',
'message' => "CodedTxt with {$CTID} deleted successfully."
'message' => "CodedTxt with ID {$CTID} deleted successfully."
]);
} catch (\Throwable $e) {
@ -172,8 +172,8 @@ class CodedText extends Controller {
private function prepareData(array $input, string $now, string $mode = 'create'): array {
$data = [
"CTGroup" => $input['LocCode'] ?? null,
"CT" => $input['Parent'] ?? null,
"CTGroup" => $input['CTGroup'] ?? null,
"CT" => $input['CT'] ?? null,
"Description" => $input['Description'] ?? null,
"FontStyle" => $input['FontStyle'] ?? null,
"Category" => $input['Category'] ?? null

View File

@ -41,13 +41,13 @@ class CodedTextField extends Controller {
public function show($CTFldID = null) {
$rows = $this->db->table('codedtxtfld')
->select("*")
->where('CTID', (int) $CTID)
->where('CTFldID', (int) $CTFldID)
->get()->getResultArray();
if (empty($rows)) {
return $this->respond([
'status' => 'success',
'message' => "CTF with ID $CTID not found.",
'message' => "CTFld with ID $CTFldID not found.",
'data' => [],
], 200);
}
@ -66,7 +66,7 @@ class CodedTextField extends Controller {
$data = $this->prepareData($input, $now, 'create');
if (!$this->validateData($data, $this->rules())) {
if (!$this->validateData($data, $this->rules)) {
return $this->failValidationErrors($this->validator->getErrors());
}
@ -108,7 +108,7 @@ class CodedTextField extends Controller {
$data = $this->prepareData($input, $now, 'update');
if (!$this->validateData($data, $this->rules())) {
if (!$this->validateData($data, $this->rules)) {
return $this->failValidationErrors( $this->validator->getErrors());
}
@ -154,7 +154,7 @@ class CodedTextField extends Controller {
return $this->failNotFound("CTFld with {$CTFldID} not found.");
}
$this->db->table('codedtxtfld')->where('CTFldID', $CTFldID)->update(['DelDate' => $this->now()]);
$this->db->table('codedtxtfld')->where('CTFldID', $CTFldID)->update(['EndDate' => $this->now]);
return $this->respondDeleted([
'status' => 'success',