Skip to content
This repository has been archived by the owner on Dec 21, 2024. It is now read-only.

Commit

Permalink
feat(save): add codes save api
Browse files Browse the repository at this point in the history
tikrack committed Sep 9, 2024
1 parent 4048892 commit b128692
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/Controllers/CodeController.php
Original file line number Diff line number Diff line change
@@ -47,13 +47,23 @@ public function save(): void
{
$request = Flight::request()->data->getData();
$rules = [
'email' => ['required', 'email']
'title' => ['required', 'string'],
'code' => ['required', 'string'],
];
$validator = new Validator($request, $rules);
$validator->validate();
$errors = $validator->errors();
if ($errors){
Flight::json($this->fail2(["errors" => $errors]));
}else {
$db = Flight::db();
$stmt = $db->prepare();
$stmt->execute([

]);
Flight::json($this->success2([
"message" => ["Code saved successfully."]
]));
}
}
}

0 comments on commit b128692

Please sign in to comment.