From: Winfried Kappeler Date: Mon, 1 Apr 2024 10:53:58 +0000 (+0200) Subject: V0.0.8 Verb X-Git-Url: https://gitweb.hamatoma.de/?a=commitdiff_plain;h=76c6e245e172a707c4a02d9bfaee06309808c77a;p=worxer.git V0.0.8 Verb - create of verb needs fewer attributes --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f86b88..c06b2b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# V0.0.8 Verb + +## Changed +- create of verb needs fewer attributes + # V0.0.8 MenuitemWorxerSeeder ## Changed diff --git a/app/Http/Controllers/VerbController.php b/app/Http/Controllers/VerbController.php index 7d9fc6a..3202652 100644 --- a/app/Http/Controllers/VerbController.php +++ b/app/Http/Controllers/VerbController.php @@ -138,27 +138,37 @@ class VerbController extends Controller */ private function rules(bool $isCreate = false): array { - $rc = [ - 'presence1s' => 'required', - 'presence2s' => 'required', - 'presence3s' => 'required', - 'presence1p' => 'required', - 'presence2p' => 'required', - 'presence3p' => 'required', - 'imperfect1s' => 'required', - 'imperfect2s' => 'required', - 'imperfect3s' => 'required', - 'imperfect1p' => 'required', - 'imperfect2p' => 'required', - 'imperfect3p' => 'required', - 'participle' => 'required', - 'separablepart' => '', - 'transitive' => 'required', - 'usage' => 'required', - 'options' => '' - ]; - if (! $isCreate){ - $rc ['word_id'] = 'required'; + if ($isCreate){ + $rc = [ + 'imperfect1s' => 'required', + 'participle' => 'required', + 'separablepart' => '', + 'transitive' => 'required', + 'usage' => 'required', + 'options' => '' + ]; + + } else { + $rc = [ + 'presence1s' => 'required', + 'presence2s' => 'required', + 'presence3s' => 'required', + 'presence1p' => 'required', + 'presence2p' => 'required', + 'presence3p' => 'required', + 'imperfect1s' => 'required', + 'imperfect2s' => 'required', + 'imperfect3s' => 'required', + 'imperfect1p' => 'required', + 'imperfect2p' => 'required', + 'imperfect3p' => 'required', + 'participle' => 'required', + 'separablepart' => '', + 'transitive' => 'required', + 'usage' => 'required', + 'options' => '', + 'word_id' => 'required' + ]; } return $rc; } @@ -208,9 +218,27 @@ class VerbController extends Controller $rc = back()->withErrors($validator)->withInput(); } else { $validated = $validator->validated(); + $base = $fields['verb']; + $base = substr($base, 0, strlen($base) - 2); + $tail1 = str_ends_with($base, 's') ? 't' : 'st'; + $tail2 = 'en'; + $tail0 = 'e'; + $validated ['presence1s'] = $base . $tail0; + $validated ['presence2s'] = $base . $tail1; + $validated ['presence3s'] = $base . $tail1; + $validated ['presence1p'] = $base . $tail2; + $validated ['presence2p'] = $base . $tail1; + $validated ['presence3p'] = $base . $tail2; + $base = $validated['imperfect1s']; + $base = substr($base, 0, strlen($base) - 1); + $validated ['imperfect2s'] = $base . $tail1; + $validated ['imperfect3s'] = $base . $tail1; + $validated ['imperfect1p'] = $base . $tail2; + $validated ['imperfect2p'] = $base . $tail1; + $validated ['imperfect3p'] = $base . $tail2; $word = Word::create([ 'word' => $fields['verb'], - 'wordtype_scope' => 2001, + 'wordtype_scope' => 2002, 'verifiedby_id' => null, 'owner_id' => auth()->id(), 'language_scope' => 1201 @@ -222,7 +250,9 @@ class VerbController extends Controller 'owner_id' => auth()->id() ]); $validated['word_id'] = $word->id; - Verb::create($validated); + $verb = Verb::create($validated); + $id = $verb->id; + $rc = redirect("/verb-edit/$id"); } } if ($rc == null) { diff --git a/composer.lock b/composer.lock index d4f0e75..9c584f7 100644 --- a/composer.lock +++ b/composer.lock @@ -2027,16 +2027,16 @@ }, { "name": "nesbot/carbon", - "version": "3.2.2", + "version": "3.2.3", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "2d69b6de67e2a3c0652d0c9dfcfda8b4563c4cee" + "reference": "4d599a6e2351d6b6bf21737accdfe1a4ce3fdbb1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/2d69b6de67e2a3c0652d0c9dfcfda8b4563c4cee", - "reference": "2d69b6de67e2a3c0652d0c9dfcfda8b4563c4cee", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/4d599a6e2351d6b6bf21737accdfe1a4ce3fdbb1", + "reference": "4d599a6e2351d6b6bf21737accdfe1a4ce3fdbb1", "shasum": "" }, "require": { @@ -2129,7 +2129,7 @@ "type": "tidelift" } ], - "time": "2024-03-28T12:59:49+00:00" + "time": "2024-03-30T18:22:00+00:00" }, { "name": "nette/schema", diff --git a/resources/views/verb/create.blade.php b/resources/views/verb/create.blade.php index 19f4b01..aa33c92 100644 --- a/resources/views/verb/create.blade.php +++ b/resources/views/verb/create.blade.php @@ -13,32 +13,8 @@ value="{{ $context->valueOf('separablepart') }}" width1="1" width2="2" /> - - - - - - - - - - - - -