WIP on form integration

This commit is contained in:
Daniel J. Summers 2023-10-07 10:57:55 -04:00
parent a5727a84fc
commit b0bf2cb083
4 changed files with 93 additions and 3 deletions

View File

@ -107,4 +107,24 @@ class Handlers
}
}
}
/** POST|PATCH /request */
public static function requestSave()
{
AppUser::require();
$form = request()->validate([
'requestId' => ['required', 'text'],
'requestText' => ['required', 'text'],
'status' => ['required', 'textOnly'],
'recurType' => ['required', 'textOnly'],
'recurCount' => 'number',
'recurInterval' => 'textOnly',
]);
if ($form) {
// valid
} else {
// errors
}
}
}

View File

@ -9,7 +9,8 @@
"guzzlehttp/psr7": "^2.6",
"http-interop/http-factory-guzzle": "^1.2",
"auth0/auth0-php": "^8.7",
"vlucas/phpdotenv": "^5.5"
"vlucas/phpdotenv": "^5.5",
"leafs/form": "^2.0"
},
"autoload": {
"psr-4": {

69
src/app/composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "14643f9ff62f769d0dc92694ad541085",
"content-hash": "5cf05fa628183ad173a48e697e23513f",
"packages": [
{
"name": "auth0/auth0-php",
@ -885,6 +885,73 @@
],
"time": "2023-07-08T12:03:30+00:00"
},
{
"name": "leafs/form",
"version": "v2.0",
"source": {
"type": "git",
"url": "https://github.com/leafsphp/form.git",
"reference": "b724596da4f52b9dc7fe1ec0cdf12b4325f369c6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/leafsphp/form/zipball/b724596da4f52b9dc7fe1ec0cdf12b4325f369c6",
"reference": "b724596da4f52b9dc7fe1ec0cdf12b4325f369c6",
"shasum": ""
},
"require": {
"ext-json": "*"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.0",
"pestphp/pest": "^1.22"
},
"type": "library",
"autoload": {
"files": [
"src/functions.php"
],
"psr-4": {
"Leaf\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Darko",
"email": "mickdd22@gmail.com",
"homepage": "https://mychi.netlify.app",
"role": "Developer"
}
],
"description": "Simple straightup data validation",
"homepage": "https://leafphp.dev/modules/forms/",
"keywords": [
"form",
"framework",
"leaf",
"php",
"validation"
],
"support": {
"issues": "https://github.com/leafsphp/form/issues",
"source": "https://github.com/leafsphp/form/tree/v2.0"
},
"funding": [
{
"url": "https://github.com/leafsphp",
"type": "github"
},
{
"url": "https://opencollective.com/leaf",
"type": "open_collective"
}
],
"time": "2023-08-19T01:07:37+00:00"
},
{
"name": "leafs/http",
"version": "v2.2.3",

View File

@ -30,7 +30,9 @@ app()->group('/legal', function () {
app()->get('/terms-of-service', fn () => Handlers::render('legal/terms-of-service', 'Terms of Service'));
});
app()->group('/request', function () {
app()->get('/{reqId}/edit', Handlers::requestEdit(...));
app()->get( '/{reqId}/edit', Handlers::requestEdit(...));
app()->post( '/request', Handlers::requestSave(...));
app()->patch('/request', Handlers::requestSave(...));
});
app()->group('/user', function () {
app()->get('/log-on', AppUser::logOn(...));